Ejemplo n.º 1
0
  /** move to next slide. */
  public void moveNextPosition(boolean smooth) {

    if (getRealAdapter() == null)
      throw new IllegalStateException("You did not set a slider adapter");

    mViewPager.setCurrentItem(mViewPager.getCurrentItem() + 1, smooth);
  }
Ejemplo n.º 2
0
 /** 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);
   }
 }
Ejemplo n.º 3
0
 /**
  * set current slider
  *
  * @param position
  */
 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);
 }
Ejemplo n.º 4
0
 /**
  * remove the slider at the position. Notice: It's a not perfect method, a very small bug still
  * exists.
  */
 public void removeSliderAt(int position) {
   if (getRealAdapter() != null) {
     getRealAdapter().removeSliderAt(position);
     mViewPager.setCurrentItem(mViewPager.getCurrentItem(), false);
   }
 }