Merge pull request #3197 from mauriciocolli/fix-main-tabs
Fix bug in main screen tabs state management
This commit is contained in:
commit
33475ef403
|
@ -136,16 +136,17 @@ public class MainFragment extends BaseFragment implements TabLayout.OnTabSelecte
|
||||||
// Tabs
|
// Tabs
|
||||||
//////////////////////////////////////////////////////////////////////////*/
|
//////////////////////////////////////////////////////////////////////////*/
|
||||||
|
|
||||||
public void setupTabs() {
|
private void setupTabs() {
|
||||||
tabsList.clear();
|
tabsList.clear();
|
||||||
tabsList.addAll(tabsManager.getTabs());
|
tabsList.addAll(tabsManager.getTabs());
|
||||||
|
|
||||||
if (pagerAdapter == null || !pagerAdapter.sameTabs(tabsList)) {
|
if (pagerAdapter == null || !pagerAdapter.sameTabs(tabsList)) {
|
||||||
pagerAdapter = new SelectedTabsPagerAdapter(requireContext(), getChildFragmentManager(), tabsList);
|
pagerAdapter = new SelectedTabsPagerAdapter(requireContext(), getChildFragmentManager(), tabsList);
|
||||||
}
|
}
|
||||||
// Clear previous tabs/fragments and set new adapter
|
|
||||||
viewPager.setAdapter(pagerAdapter);
|
viewPager.setAdapter(null);
|
||||||
viewPager.setOffscreenPageLimit(tabsList.size());
|
viewPager.setOffscreenPageLimit(tabsList.size());
|
||||||
|
viewPager.setAdapter(pagerAdapter);
|
||||||
|
|
||||||
updateTabsIconAndDescription();
|
updateTabsIconAndDescription();
|
||||||
updateTitleForTab(viewPager.getCurrentItem());
|
updateTitleForTab(viewPager.getCurrentItem());
|
||||||
|
@ -194,6 +195,7 @@ public class MainFragment extends BaseFragment implements TabLayout.OnTabSelecte
|
||||||
this.internalTabsList = new ArrayList<>(tabsList);
|
this.internalTabsList = new ArrayList<>(tabsList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public Fragment getItem(int position) {
|
public Fragment getItem(int position) {
|
||||||
final Tab tab = internalTabsList.get(position);
|
final Tab tab = internalTabsList.get(position);
|
||||||
|
|
Loading…
Reference in New Issue