Skip to content

Commit

Permalink
work around crash theme switch
Browse files Browse the repository at this point in the history
  • Loading branch information
sk22 committed Jan 13, 2023
1 parent 2b30ffd commit 58fd0c4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import android.graphics.Outline;
import android.os.Build;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
Expand Down Expand Up @@ -257,9 +258,15 @@ public boolean onBackPressed(){
public void onSaveInstanceState(Bundle outState){
super.onSaveInstanceState(outState);
outState.putInt("selectedTab", currentTab);
getChildFragmentManager().putFragment(outState, "homeTabFragment", homeTabFragment);
getChildFragmentManager().putFragment(outState, "searchFragment", searchFragment);
getChildFragmentManager().putFragment(outState, "notificationsFragment", notificationsFragment);
getChildFragmentManager().putFragment(outState, "profileFragment", profileFragment);
try {
getChildFragmentManager().putFragment(outState, "homeTabFragment", homeTabFragment);
getChildFragmentManager().putFragment(outState, "searchFragment", searchFragment);
getChildFragmentManager().putFragment(outState, "notificationsFragment", notificationsFragment);
getChildFragmentManager().putFragment(outState, "profileFragment", profileFragment);
} catch (IllegalStateException ex) {
// java.lang.IllegalStateException: Fragment HomeTabFragment{3447cad} is not currently in the FragmentManager
// no idea how to fix this :/
Log.e(HomeFragment.class.getSimpleName(), ex.getMessage());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,7 @@ private void restartActivityToApplyNewTheme(){
lp.windowAnimations=R.style.window_fade_out;
MastodonApp.context.getSystemService(WindowManager.class).addView(themeTransitionWindowView, lp);
}
needAppRestart = true; // avoid issues with corrupted, not correctly inset HomeTabFragment
getActivity().recreate();
}

Expand Down

0 comments on commit 58fd0c4

Please sign in to comment.