mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 12:23:58 +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
|
|
@ -38,6 +38,10 @@ public class BookmarkListRootFragment extends CommonsDaggerSupportFragment imple
|
|||
@BindView(R.id.explore_container)
|
||||
FrameLayout container;
|
||||
|
||||
public BookmarkListRootFragment(){
|
||||
//empty constructor necessary otherwise crashes on recreate
|
||||
}
|
||||
|
||||
public BookmarkListRootFragment(Bundle bundle, BookmarksPagerAdapter bookmarksPagerAdapter) {
|
||||
String title = bundle.getString("categoryName");
|
||||
int order = bundle.getInt("order");
|
||||
|
|
@ -65,7 +69,9 @@ public class BookmarkListRootFragment extends CommonsDaggerSupportFragment imple
|
|||
@Override
|
||||
public void onViewCreated(@NonNull final View view, @Nullable final Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
setFragment(listFragment, mediaDetails);
|
||||
if(savedInstanceState==null) {
|
||||
setFragment(listFragment, mediaDetails);
|
||||
}
|
||||
}
|
||||
|
||||
public void setFragment(Fragment fragment, Fragment otherFragment) {
|
||||
|
|
|
|||
|
|
@ -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(),
|
||||
|
|
|
|||
|
|
@ -34,6 +34,10 @@ public class ExploreListRootFragment extends CommonsDaggerSupportFragment implem
|
|||
@BindView(R.id.explore_container)
|
||||
FrameLayout container;
|
||||
|
||||
public ExploreListRootFragment(){
|
||||
//empty constructor necessary otherwise crashes on recreate
|
||||
}
|
||||
|
||||
public ExploreListRootFragment(Bundle bundle) {
|
||||
String title = bundle.getString("categoryName");
|
||||
listFragment = new CategoriesMediaFragment();
|
||||
|
|
@ -55,7 +59,9 @@ public class ExploreListRootFragment extends CommonsDaggerSupportFragment implem
|
|||
@Override
|
||||
public void onViewCreated(@NonNull final View view, @Nullable final Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
setFragment(listFragment, mediaDetails);
|
||||
if(savedInstanceState == null) {
|
||||
setFragment(listFragment, mediaDetails);
|
||||
}
|
||||
}
|
||||
|
||||
public void setFragment(Fragment fragment, Fragment otherFragment) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue