Use tab position from parameters instead of relying on the view pager
This commit is contained in:
parent
38a0395d45
commit
544cae4fb4
1 changed files with 5 additions and 5 deletions
|
@ -147,7 +147,7 @@ public class MainFragment extends BaseFragment implements TabLayout.OnTabSelecte
|
||||||
viewPager.setOffscreenPageLimit(tabsList.size());
|
viewPager.setOffscreenPageLimit(tabsList.size());
|
||||||
|
|
||||||
updateTabsIconAndDescription();
|
updateTabsIconAndDescription();
|
||||||
updateCurrentTitle();
|
updateTitleForTab(viewPager.getCurrentItem());
|
||||||
|
|
||||||
hasTabsChanged = false;
|
hasTabsChanged = false;
|
||||||
}
|
}
|
||||||
|
@ -163,14 +163,14 @@ public class MainFragment extends BaseFragment implements TabLayout.OnTabSelecte
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateCurrentTitle() {
|
private void updateTitleForTab(int tabPosition) {
|
||||||
setTitle(tabsList.get(viewPager.getCurrentItem()).getTabName(requireContext()));
|
setTitle(tabsList.get(tabPosition).getTabName(requireContext()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onTabSelected(TabLayout.Tab selectedTab) {
|
public void onTabSelected(TabLayout.Tab selectedTab) {
|
||||||
if (DEBUG) Log.d(TAG, "onTabSelected() called with: selectedTab = [" + selectedTab + "]");
|
if (DEBUG) Log.d(TAG, "onTabSelected() called with: selectedTab = [" + selectedTab + "]");
|
||||||
updateCurrentTitle();
|
updateTitleForTab(selectedTab.getPosition());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -180,7 +180,7 @@ public class MainFragment extends BaseFragment implements TabLayout.OnTabSelecte
|
||||||
@Override
|
@Override
|
||||||
public void onTabReselected(TabLayout.Tab tab) {
|
public void onTabReselected(TabLayout.Tab tab) {
|
||||||
if (DEBUG) Log.d(TAG, "onTabReselected() called with: tab = [" + tab + "]");
|
if (DEBUG) Log.d(TAG, "onTabReselected() called with: tab = [" + tab + "]");
|
||||||
updateCurrentTitle();
|
updateTitleForTab(tab.getPosition());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class SelectedTabsPagerAdapter extends FragmentStatePagerAdapter {
|
private static class SelectedTabsPagerAdapter extends FragmentStatePagerAdapter {
|
||||||
|
|
Loading…
Reference in a new issue