Search in sources :

Example 1 with TravelViewPagerAdapter

use of com.qslll.expandingpager.adapter.TravelViewPagerAdapter in project ExpandingPager by qs-lll.

the class MainActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    ButterKnife.bind(this);
    setupWindowAnimations();
    TravelViewPagerAdapter adapter = new TravelViewPagerAdapter(getSupportFragmentManager());
    adapter.addAll(generateTravelList());
    viewPager.setAdapter(adapter);
    ExpandingPagerFactory.setupViewPager(viewPager);
    viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {

        @Override
        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
            ExpandingFragment expandingFragment = ExpandingPagerFactory.getCurrentFragment(viewPager);
            if (expandingFragment != null && expandingFragment.isOpenend()) {
                expandingFragment.close();
            }
        }

        @Override
        public void onPageSelected(int position) {
        }

        @Override
        public void onPageScrollStateChanged(int state) {
        }
    });
}
Also used : TravelViewPagerAdapter(com.qslll.expandingpager.adapter.TravelViewPagerAdapter) ExpandingFragment(com.qslll.library.fragments.ExpandingFragment) ViewPager(android.support.v4.view.ViewPager)

Aggregations

ViewPager (android.support.v4.view.ViewPager)1 TravelViewPagerAdapter (com.qslll.expandingpager.adapter.TravelViewPagerAdapter)1 ExpandingFragment (com.qslll.library.fragments.ExpandingFragment)1