mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-29 22:03:55 +01:00
Fix (#4148) Issues on theme change
* fixed themeChange crashes * fixed comments * Overlooked the title bar
This commit is contained in:
parent
2d884b44ca
commit
c4bd23f7a1
3 changed files with 26 additions and 9 deletions
|
|
@ -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(),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue