/** remove all the sliders. Notice: It's a not perfect method, a very small bug still exists. */ public void removeAllSliders() { if (getRealAdapter() != null) { int count = getRealAdapter().getCount(); getRealAdapter().removeAllSliders(); // a small bug, but fixed by this trick. // bug: when remove adapter's all the sliders.some caching slider still alive. mViewPager.setCurrentItem(mViewPager.getCurrentItem() + count, false); } }
/** * move to the next slide * * @param smooth bool */ public void moveNextPosition(boolean smooth) { if (getRealAdapter() == null) throw new IllegalStateException("You did not set a slider adapter"); mViewPager.setCurrentItem(mViewPager.getCurrentItem() + 1, smooth); if (mIsShuffle) { setPagerTransformer(true, getShuffleTransformer()); } }
/** * set the current slider * * @param position the insert position * @param smooth if that is smooth or not */ public void setCurrentPosition(int position, boolean smooth) { if (getRealAdapter() == null) throw new IllegalStateException("You did not set a slider adapter"); if (position >= getRealAdapter().getCount()) { throw new IllegalStateException("Item position is not exist"); } int p = mViewPager.getCurrentItem() % getRealAdapter().getCount(); int n = (position - p) + mViewPager.getCurrentItem(); mViewPager.setCurrentItem(n, smooth); }
/** * move to prev slide. * * @param smooth bool */ public void movePrevPosition(boolean smooth) { if (getRealAdapter() == null) throw new IllegalStateException("You did not set a slider adapter"); mViewPager.setCurrentItem(mViewPager.getCurrentItem() - 1, smooth); }