Fixed duplicate legend page titles on rotate

This commit is contained in:
M66B 2019-07-30 10:28:01 +02:00
parent d99f19f2b6
commit 1f5e98ca16
1 changed files with 12 additions and 0 deletions

View File

@ -48,6 +48,9 @@ public class FragmentLegend extends FragmentBase {
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
setSubtitle(R.string.menu_legend);
if (savedInstanceState != null)
layout = savedInstanceState.getInt("fair:layout");
View view;
if (layout < 0) {
view = inflater.inflate(R.layout.fragment_legend, container, false);
@ -63,12 +66,21 @@ public class FragmentLegend extends FragmentBase {
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
if (savedInstanceState != null)
layout = savedInstanceState.getInt("fair:layout");
if (layout < 0) {
TabLayout tabLayout = view.findViewById(R.id.tab_layout);
tabLayout.setupWithViewPager(pager);
}
}
@Override
public void onSaveInstanceState(Bundle outState) {
outState.putInt("fair:layout", layout);
super.onSaveInstanceState(outState);
}
private class PagerAdapter extends FragmentStatePagerAdapter {
public PagerAdapter(FragmentManager fm) {
super(fm);