Search in sources :

Example 1 with ImagesContainerPagerAdapter

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

the class ImagesContainerFragment method initializePagerViews.

@Override
public void initializePagerViews(final List<BaseEntity> categoryList) {
    if (null != categoryList && !categoryList.isEmpty()) {
        mViewPager.setOffscreenPageLimit(categoryList.size());
        mViewPager.setAdapter(new ImagesContainerPagerAdapter(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) {
                ImagesListFragment fragment = (ImagesListFragment) mViewPager.getAdapter().instantiateItem(mViewPager, position);
                fragment.onPageSelected(position, categoryList.get(position).getId());
            }

            @Override
            public void onPageScrollStateChanged(int state) {
            }
        });
    }
}
Also used : ImagesContainerPagerAdapter(com.github.obsessive.simplifyreader.ui.adpter.ImagesContainerPagerAdapter) 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 ImagesContainerPagerAdapter (com.github.obsessive.simplifyreader.ui.adpter.ImagesContainerPagerAdapter)1