1
0
mirror of https://github.com/TeamNewPipe/NewPipe.git synced 2024-11-25 20:42:34 +01:00

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

View File

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