forked from github/wulkanowy-mirror
Save current tab position in exams (#102)
This commit is contained in:
parent
67f83a4d2f
commit
8e855bd375
@ -21,6 +21,8 @@ import io.github.wulkanowy.ui.main.OnFragmentIsReadyListener;
|
|||||||
|
|
||||||
public class ExamsFragment extends BaseFragment implements ExamsContract.View {
|
public class ExamsFragment extends BaseFragment implements ExamsContract.View {
|
||||||
|
|
||||||
|
private static final String CURRENT_ITEM_KEY = "CurrentItem";
|
||||||
|
|
||||||
@BindView(R.id.exams_fragment_viewpager)
|
@BindView(R.id.exams_fragment_viewpager)
|
||||||
ViewPager viewPager;
|
ViewPager viewPager;
|
||||||
|
|
||||||
@ -43,6 +45,10 @@ public class ExamsFragment extends BaseFragment implements ExamsContract.View {
|
|||||||
component.inject(this);
|
component.inject(this);
|
||||||
setButterKnife(ButterKnife.bind(this, view));
|
setButterKnife(ButterKnife.bind(this, view));
|
||||||
presenter.onStart(this, (OnFragmentIsReadyListener) getActivity());
|
presenter.onStart(this, (OnFragmentIsReadyListener) getActivity());
|
||||||
|
|
||||||
|
if (savedInstanceState != null) {
|
||||||
|
presenter.setRestoredPosition(savedInstanceState.getInt(CURRENT_ITEM_KEY));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
@ -92,6 +98,12 @@ public class ExamsFragment extends BaseFragment implements ExamsContract.View {
|
|||||||
tabLayout.setupWithViewPager(viewPager);
|
tabLayout.setupWithViewPager(viewPager);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSaveInstanceState(Bundle outState) {
|
||||||
|
outState.putInt(CURRENT_ITEM_KEY, viewPager.getCurrentItem());
|
||||||
|
super.onSaveInstanceState(outState);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDestroyView() {
|
public void onDestroyView() {
|
||||||
super.onDestroyView();
|
super.onDestroyView();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user