restore current tab

This commit is contained in:
sk 2023-01-16 14:46:12 +01:00 committed by LucasGGamerM
parent 31f9173126
commit aec2704f15
1 changed files with 18 additions and 1 deletions

View File

@ -338,7 +338,11 @@ public class HomeTabFragment extends MastodonToolbarFragment implements Scrollab
} }
private void navigateTo(int i) { 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); 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> { private class HomePagerAdapter extends RecyclerView.Adapter<SimpleViewHolder> {
@NonNull @NonNull
@Override @Override