restore current tab
This commit is contained in:
parent
31f9173126
commit
aec2704f15
|
@ -338,7 +338,11 @@ public class HomeTabFragment extends MastodonToolbarFragment implements Scrollab
|
|||
}
|
||||
|
||||
private void navigateTo(int i) {
|
||||
pager.setCurrentItem(i);
|
||||
navigateTo(i, !GlobalUserPreferences.reduceMotion);
|
||||
}
|
||||
|
||||
private void navigateTo(int i, boolean smooth) {
|
||||
pager.setCurrentItem(i, smooth);
|
||||
updateSwitcherIcon(i);
|
||||
}
|
||||
|
||||
|
@ -484,6 +488,19 @@ public class HomeTabFragment extends MastodonToolbarFragment implements Scrollab
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewStateRestored(Bundle savedInstanceState) {
|
||||
super.onViewStateRestored(savedInstanceState);
|
||||
if (savedInstanceState == null) return;
|
||||
navigateTo(savedInstanceState.getInt("selectedTab"), false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSaveInstanceState(Bundle outState) {
|
||||
super.onSaveInstanceState(outState);
|
||||
outState.putInt("selectedTab", pager.getCurrentItem());
|
||||
}
|
||||
|
||||
private class HomePagerAdapter extends RecyclerView.Adapter<SimpleViewHolder> {
|
||||
@NonNull
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue