Search in sources :

Example 1 with VideosContainerPagerAdapter

use of com.github.obsessive.simplifyreader.ui.adpter.VideosContainerPagerAdapter in project SimplifyReader by chentao0707.

the class VideosContainerFragment method initializePagerViews.

@Override
public void initializePagerViews(final List<BaseEntity> categoryList) {
    if (null != categoryList && !categoryList.isEmpty()) {
        mViewPager.setOffscreenPageLimit(categoryList.size());
        mViewPager.setAdapter(new VideosContainerPagerAdapter(getSupportFragmentManager(), categoryList));
        mSmartTabLayout.setViewPager(mViewPager);
        mSmartTabLayout.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {

            @Override
            public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
            }

            @Override
            public void onPageSelected(int position) {
                VideosListFragment fragment = (VideosListFragment) mViewPager.getAdapter().instantiateItem(mViewPager, position);
                fragment.onPageSelected(position, categoryList.get(position).getId());
            }

            @Override
            public void onPageScrollStateChanged(int state) {
            }
        });
    }
}
Also used : VideosContainerPagerAdapter(com.github.obsessive.simplifyreader.ui.adpter.VideosContainerPagerAdapter) ViewPager(android.support.v4.view.ViewPager) XViewPager(com.github.obsessive.library.widgets.XViewPager)

Aggregations

ViewPager (android.support.v4.view.ViewPager)1 XViewPager (com.github.obsessive.library.widgets.XViewPager)1 VideosContainerPagerAdapter (com.github.obsessive.simplifyreader.ui.adpter.VideosContainerPagerAdapter)1