Search in sources :

Example 1 with FeedFragment

use of org.wikipedia.feed.FeedFragment 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;
}
Also used : NavTabFragmentPagerAdapter(org.wikipedia.navtab.NavTabFragmentPagerAdapter) HorizontalScrollingListCardItemView(org.wikipedia.feed.view.HorizontalScrollingListCardItemView) BindView(butterknife.BindView) View(android.view.View) SearchFragment(org.wikipedia.search.SearchFragment) Fragment(android.support.v4.app.Fragment) HistoryFragment(org.wikipedia.history.HistoryFragment) NearbyFragment(org.wikipedia.nearby.NearbyFragment) FeedFragment(org.wikipedia.feed.FeedFragment) FeedFragment(org.wikipedia.feed.FeedFragment) Nullable(android.support.annotation.Nullable)

Example 2 with FeedFragment

use of org.wikipedia.feed.FeedFragment 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());
}
Also used : NavTabFragmentPagerAdapter(org.wikipedia.navtab.NavTabFragmentPagerAdapter) SearchFragment(org.wikipedia.search.SearchFragment) Fragment(android.support.v4.app.Fragment) HistoryFragment(org.wikipedia.history.HistoryFragment) NearbyFragment(org.wikipedia.nearby.NearbyFragment) FeedFragment(org.wikipedia.feed.FeedFragment) FeedFragment(org.wikipedia.feed.FeedFragment)

Aggregations

Fragment (android.support.v4.app.Fragment)2 FeedFragment (org.wikipedia.feed.FeedFragment)2 HistoryFragment (org.wikipedia.history.HistoryFragment)2 NavTabFragmentPagerAdapter (org.wikipedia.navtab.NavTabFragmentPagerAdapter)2 NearbyFragment (org.wikipedia.nearby.NearbyFragment)2 SearchFragment (org.wikipedia.search.SearchFragment)2 Nullable (android.support.annotation.Nullable)1 View (android.view.View)1 BindView (butterknife.BindView)1 HorizontalScrollingListCardItemView (org.wikipedia.feed.view.HorizontalScrollingListCardItemView)1