use of org.wikipedia.navtab.NavTabFragmentPagerAdapter in project apps-android-wikipedia by wikimedia.
the class MainFragment method onCreateView.
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
super.onCreateView(inflater, container, savedInstanceState);
View view = inflater.inflate(R.layout.fragment_main, container, false);
unbinder = ButterKnife.bind(this, view);
viewPager.setAdapter(new NavTabFragmentPagerAdapter(getChildFragmentManager()));
tabLayout.setOnNavigationItemSelectedListener(item -> {
Fragment fragment = ((NavTabFragmentPagerAdapter) viewPager.getAdapter()).getCurrentFragment();
if (fragment instanceof FeedFragment && item.getOrder() == 0) {
((FeedFragment) fragment).scrollToTop();
}
viewPager.setCurrentItem(item.getOrder());
return true;
});
if (savedInstanceState == null) {
handleIntent(getActivity().getIntent());
}
return view;
}
use of org.wikipedia.navtab.NavTabFragmentPagerAdapter in project apps-android-wikipedia by wikimedia.
the class MainFragment method requestUpdateToolbarElevation.
public void requestUpdateToolbarElevation() {
Fragment fragment = ((NavTabFragmentPagerAdapter) viewPager.getAdapter()).getCurrentFragment();
updateToolbarElevation(!(fragment instanceof FeedFragment) || ((FeedFragment) fragment).shouldElevateToolbar());
}
use of org.wikipedia.navtab.NavTabFragmentPagerAdapter in project apps-android-wikipedia by wikimedia.
the class MainFragment method onBackPressed.
@Override
public boolean onBackPressed() {
SearchFragment searchFragment = searchFragment();
if (searchFragment != null && searchFragment.onBackPressed()) {
return true;
}
Fragment fragment = ((NavTabFragmentPagerAdapter) viewPager.getAdapter()).getCurrentFragment();
if (fragment instanceof BackPressedHandler && ((BackPressedHandler) fragment).onBackPressed()) {
return true;
}
return false;
}
Aggregations