Search in sources :

Example 1 with BannerPagerAdapter

use of pri.weiqiang.liyujapanese.ui.adapter.BannerPagerAdapter in project LiYuJapanese by 54wall.

the class MainActivity method setViewPager.

@Override
public void setViewPager(final List<BannerItem> data) {
    if (bannerSubscription != null && bannerSubscription.isUnsubscribed()) {
        bannerSubscription.unsubscribe();
    }
    mBannerViewPager.setAdapter(new BannerPagerAdapter(getSupportFragmentManager(), data));
    mCircleIndicator.setViewPager(mBannerViewPager);
    bannerSubscription = Observable.timer(10, 10, TimeUnit.SECONDS).observeOn(AndroidSchedulers.mainThread()).subscribeOn(Schedulers.io()).subscribe(new Action1<Long>() {

        @Override
        public void call(Long aLong) {
            int next = (mBannerViewPager.getCurrentItem() + 1) % data.size();
            mBannerViewPager.setCurrentItem(next);
        }
    });
}
Also used : BannerPagerAdapter(pri.weiqiang.liyujapanese.ui.adapter.BannerPagerAdapter) Action1(rx.functions.Action1)

Aggregations

BannerPagerAdapter (pri.weiqiang.liyujapanese.ui.adapter.BannerPagerAdapter)1 Action1 (rx.functions.Action1)1