use of pri.weiqiang.myjapanese.ui.adapter.BannerPagerAdapter in project MyJapanese 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