fix: ChannelFragment: save last tab

This commit is contained in:
ThetaDev 2022-11-22 02:52:25 +01:00 committed by Stypox
parent 2c03ba204e
commit 4357a34339
No known key found for this signature in database
GPG Key ID: 4BDF1B40A49FDD23
1 changed files with 12 additions and 0 deletions

View File

@ -100,6 +100,12 @@ public class ChannelFragment extends BaseStateFragment<ChannelInfo>
public void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setHasOptionsMenu(true);
if (savedInstanceState != null) {
lastTab = savedInstanceState.getInt("LastTab");
} else {
lastTab = 0;
}
}
@Override
@ -125,6 +131,12 @@ public class ChannelFragment extends BaseStateFragment<ChannelInfo>
binding.tabLayout.setupWithViewPager(binding.viewPager);
}
@Override
public void onSaveInstanceState(final @NonNull Bundle outState) {
super.onSaveInstanceState(outState);
outState.putInt("LastTab", binding.tabLayout.getSelectedTabPosition());
}
@Override
public void onDestroy() {
super.onDestroy();