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);
}
});
}
Aggregations