Fix (#4148) Issues on theme change

* fixed themeChange crashes

* fixed comments

* Overlooked the title bar
This commit is contained in:
Aditya-Srivastav 2021-01-11 19:51:44 +05:30 committed by GitHub
parent 2d884b44ca
commit c4bd23f7a1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 26 additions and 9 deletions

View file

@ -113,7 +113,11 @@ public class MainActivity extends BaseActivity
setTitle(getString(R.string.explore_tab_title_mobile));
setUpLoggedOutPager();
} else {
setTitle(getString(R.string.contributions_fragment));
if(savedInstanceState == null){
//starting a fresh fragment.
setTitle(getString(R.string.contributions_fragment));
loadFragment(ContributionsFragment.newInstance(),false);
}
setUpPager();
initMain();
}
@ -124,30 +128,31 @@ public class MainActivity extends BaseActivity
}
private void setUpPager() {
loadFragment(ContributionsFragment.newInstance());
tabLayout.setOnNavigationItemSelectedListener(item -> {
if (!item.getTitle().equals("More")) {
// do not change title for more fragment
setTitle(item.getTitle());
}
Fragment fragment = NavTab.of(item.getOrder()).newInstance();
return loadFragment(fragment);
return loadFragment(fragment,true);
});
}
private void setUpLoggedOutPager() {
loadFragment(ExploreFragment.newInstance());
loadFragment(ExploreFragment.newInstance(),false);
tabLayout.setOnNavigationItemSelectedListener(item -> {
if (!item.getTitle().equals("More")) {
// do not change title for more fragment
setTitle(item.getTitle());
}
Fragment fragment = NavTabLoggedOut.of(item.getOrder()).newInstance();
return loadFragment(fragment);
return loadFragment(fragment,true);
});
}
private boolean loadFragment(Fragment fragment) {
private boolean loadFragment(Fragment fragment,boolean showBottom ) {
//showBottom so that we do not show the bottom tray again when constructing
//from the saved instance state.
if (fragment instanceof ContributionsFragment) {
if (activeFragment == ActiveFragment.CONTRIBUTIONS) { // Do nothing if same tab
return true;
@ -172,7 +177,7 @@ public class MainActivity extends BaseActivity
}
bookmarkFragment = (BookmarkFragment) fragment;
activeFragment = ActiveFragment.BOOKMARK;
} else if (fragment == null) {
} else if (fragment == null && showBottom) {
if (applicationKvStore.getBoolean("login_skipped") == true) { // If logged out, more sheet is different
MoreBottomSheetLoggedOutFragment bottomSheet = new MoreBottomSheetLoggedOutFragment();
bottomSheet.show(getSupportFragmentManager(),