Browse Source

deprecated some methods

zhpanvip 5 years ago
parent
commit
21f31df52e

+ 1 - 1
bannerview/build.gradle

@@ -32,7 +32,7 @@ dependencies {
     implementation 'com.android.support:appcompat-v7:27.1.1'
 }
 
-version = "2.6.6"
+version = "2.7.1"
 def siteUrl = 'https://github.com/zhpanvip/BannerViewPager'      // 项目的主页
 def gitUrl = 'https://github.com/zhpanvip/BannerViewPager.git'   // Git仓库的url
 group = "com.zhpan.library" // Maven Group ID for the artifact,一般填你唯一的包名

+ 123 - 63
bannerview/src/main/java/com/zhpan/bannerview/BannerViewPager.java

@@ -20,8 +20,6 @@ import com.zhpan.bannerview.annotation.AIndicatorStyle;
 import com.zhpan.bannerview.annotation.APageStyle;
 import com.zhpan.bannerview.annotation.ATransformerStyle;
 import com.zhpan.bannerview.annotation.Visibility;
-import com.zhpan.bannerview.constants.IndicatorSlideMode;
-import com.zhpan.bannerview.constants.IndicatorStyle;
 import com.zhpan.bannerview.constants.PageStyle;
 import com.zhpan.bannerview.indicator.IndicatorView;
 import com.zhpan.bannerview.indicator.IIndicator;
@@ -230,7 +228,8 @@ public class BannerViewPager<T, VH extends ViewHolder> extends RelativeLayout im
             initIndicator(new IndicatorView(getContext()));
         }
         mIndicatorView.setIndicatorOptions(bannerOptions.getIndicatorOptions());
-        mIndicatorView.setPageSize(list.size());
+        bannerOptions.getIndicatorOptions().setPageSize(list.size());
+        mIndicatorView.notifyDataChanged();
     }
 
     private void initIndicator(IIndicator indicatorView) {
@@ -515,65 +514,57 @@ public class BannerViewPager<T, VH extends ViewHolder> extends RelativeLayout im
      * @param checkedColor checked color of indicator
      * @param normalColor  unchecked color of indicator
      */
-    public BannerViewPager<T, VH> setIndicatorColor(@ColorInt int normalColor,
-                                                    @ColorInt int checkedColor) {
-        mBannerManager.bannerOptions().setIndicatorCheckedColor(checkedColor);
-        mBannerManager.bannerOptions().setIndicatorNormalColor(normalColor);
+    public BannerViewPager<T, VH> setIndicatorSliderColor(@ColorInt int normalColor,
+                                                          @ColorInt int checkedColor) {
+        mBannerManager.bannerOptions().setIndicatorSliderColor(normalColor, checkedColor);
         return this;
     }
 
+
     /**
      * set indicator circle radius
      * <p>
-     * if the indicator style is {@link IndicatorStyle#DASH} or {@link IndicatorStyle#ROUND_RECT}
+     * if the indicator style is {@link com.zhpan.indicator.enums.IndicatorStyle#DASH}
+     * or {@link com.zhpan.indicator.enums.IndicatorStyle#ROUND_RECT}
      * the indicator dash width=2*radius
      *
      * @param radius 指示器圆点半径
      */
-    public BannerViewPager<T, VH> setIndicatorRadius(int radius) {
-        setIndicatorRadius(radius, radius);
+    public BannerViewPager<T, VH> setIndicatorSliderRadius(int radius) {
+        setIndicatorSliderRadius(radius, radius);
         return this;
     }
 
+
     /**
      * set indicator circle radius
      *
      * @param normalRadius  unchecked circle radius
      * @param checkedRadius checked circle radius
      */
-    public BannerViewPager<T, VH> setIndicatorRadius(int normalRadius, int checkedRadius) {
-        mBannerManager.bannerOptions().setNormalIndicatorWidth(normalRadius * 2);
-        mBannerManager.bannerOptions().setCheckedIndicatorWidth(checkedRadius * 2);
+    public BannerViewPager<T, VH> setIndicatorSliderRadius(int normalRadius, int checkedRadius) {
+        mBannerManager.bannerOptions().setIndicatorSliderWidth(normalRadius * 2, checkedRadius * 2);
         return this;
     }
 
-
-    /**
-     * Set indicator dash width,if indicator style is {@link IndicatorStyle#CIRCLE},
-     * the indicator circle radius is indicatorWidth/2.
-     *
-     * @param indicatorWidth indicator dash width.
-     */
-    public BannerViewPager<T, VH> setIndicatorWidth(int indicatorWidth) {
-        setIndicatorWidth(indicatorWidth, indicatorWidth);
+    public BannerViewPager<T, VH> setIndicatorSliderWidth(int indicatorWidth) {
+        setIndicatorSliderWidth(indicatorWidth, indicatorWidth);
         return this;
     }
 
-
     /**
-     * Set indicator dash width,if indicator style is {@link IndicatorStyle#CIRCLE},
+     * Set indicator dash width,if indicator style is {@link com.zhpan.indicator.enums.IndicatorStyle#CIRCLE},
      * the indicator circle radius is indicatorWidth/2.
      *
-     * @param normalWidth if the indicator style is {@link IndicatorStyle#DASH} the params means unchecked dash width
-     *                    if the indicator style is {@link IndicatorStyle#ROUND_RECT}  means unchecked round rectangle width
-     *                    if the indicator style is {@link IndicatorStyle#CIRCLE } means unchecked circle diameter
-     * @param checkWidth  if the indicator style is {@link IndicatorStyle#DASH} the params means checked dash width
-     *                    if the indicator style is {@link IndicatorStyle#ROUND_RECT} the params means checked round rectangle width
-     *                    if the indicator style is {@link IndicatorStyle#CIRCLE } means checked circle diameter
-     */
-    public BannerViewPager<T, VH> setIndicatorWidth(int normalWidth, int checkWidth) {
-        mBannerManager.bannerOptions().setNormalIndicatorWidth(normalWidth);
-        mBannerManager.bannerOptions().setCheckedIndicatorWidth(checkWidth);
+     * @param normalWidth if the indicator style is {@link com.zhpan.indicator.enums.IndicatorStyle#DASH} the params means unchecked dash width
+     *                    if the indicator style is {@link com.zhpan.indicator.enums.IndicatorStyle#ROUND_RECT}  means unchecked round rectangle width
+     *                    if the indicator style is {@link com.zhpan.indicator.enums.IndicatorStyle#CIRCLE } means unchecked circle diameter
+     * @param checkWidth  if the indicator style is {@link com.zhpan.indicator.enums.IndicatorStyle#DASH} the params means checked dash width
+     *                    if the indicator style is {@link com.zhpan.indicator.enums.IndicatorStyle#ROUND_RECT} the params means checked round rectangle width
+     *                    if the indicator style is {@link com.zhpan.indicator.enums.IndicatorStyle#CIRCLE } means checked circle diameter
+     */
+    public BannerViewPager<T, VH> setIndicatorSliderWidth(int normalWidth, int checkWidth) {
+        mBannerManager.bannerOptions().setIndicatorSliderWidth(normalWidth, checkWidth);
         return this;
     }
 
@@ -587,21 +578,11 @@ public class BannerViewPager<T, VH extends ViewHolder> extends RelativeLayout im
      *
      * @param indicatorGap indicator gap
      */
-    public BannerViewPager<T, VH> setIndicatorGap(int indicatorGap) {
+    public BannerViewPager<T, VH> setIndicatorSliderGap(int indicatorGap) {
         mBannerManager.bannerOptions().setIndicatorGap(indicatorGap);
         return this;
     }
 
-    /**
-     * @param showIndicator is show indicator
-     * @deprecated Use {@link #setIndicatorVisibility(int)} instead.
-     */
-    @Deprecated
-    public BannerViewPager<T, VH> showIndicator(boolean showIndicator) {
-        mIndicatorLayout.setVisibility(showIndicator ? VISIBLE : GONE);
-        return this;
-    }
-
     /**
      * Set the visibility state of indicator view.
      *
@@ -626,11 +607,11 @@ public class BannerViewPager<T, VH extends ViewHolder> extends RelativeLayout im
     }
 
     /**
-     * Set Indicator slide mode,default value is {@link IndicatorSlideMode#NORMAL}
+     * Set Indicator slide mode,default value is {@link com.zhpan.indicator.enums.IndicatorSlideMode#NORMAL}
      *
      * @param slideMode Indicator slide mode
-     * @see com.zhpan.bannerview.constants.IndicatorSlideMode#NORMAL
-     * @see com.zhpan.bannerview.constants.IndicatorSlideMode#SMOOTH
+     * @see com.zhpan.indicator.enums.IndicatorSlideMode#NORMAL
+     * @see com.zhpan.indicator.enums.IndicatorSlideMode#SMOOTH
      */
     public BannerViewPager<T, VH> setIndicatorSlideMode(@AIndicatorSlideMode int slideMode) {
         mBannerManager.bannerOptions().setIndicatorSlideMode(slideMode);
@@ -656,9 +637,9 @@ public class BannerViewPager<T, VH extends ViewHolder> extends RelativeLayout im
      * Set indicator style
      *
      * @param indicatorStyle indicator style
-     * @see IndicatorStyle#CIRCLE
-     * @see IndicatorStyle#DASH
-     * @see IndicatorStyle#ROUND_RECT
+     * @see com.zhpan.indicator.enums.IndicatorStyle#CIRCLE
+     * @see com.zhpan.indicator.enums.IndicatorStyle#DASH
+     * @see com.zhpan.indicator.enums.IndicatorStyle#ROUND_RECT
      */
     public BannerViewPager<T, VH> setIndicatorStyle(@AIndicatorStyle int indicatorStyle) {
         mBannerManager.bannerOptions().setIndicatorStyle(indicatorStyle);
@@ -674,18 +655,6 @@ public class BannerViewPager<T, VH extends ViewHolder> extends RelativeLayout im
         initBannerData(list);
     }
 
-//    public void update(List<T> list) {
-//        if (null != list) {
-//            if (mBannerPagerAdapter != null && mBannerManager.bannerOptions().getPageStyle() == PageStyle.NORMAL) {
-//                mBannerPagerAdapter.setList(list);
-//                mIndicatorView.setPageSize(list.size());
-////                setCurrentItem(0, false);
-//            } else {
-//                initBannerData(list);
-//            }
-//        }
-//    }
-
     /**
      * @return the currently selected page position.
      */
@@ -793,4 +762,95 @@ public class BannerViewPager<T, VH extends ViewHolder> extends RelativeLayout im
         mOnPageChangeListener = onPageChangeListener;
         return this;
     }
+
+
+    /**
+     * set indicator circle radius
+     *
+     * @param normalRadius  unchecked circle radius
+     * @param checkedRadius checked circle radius
+     * @deprecated use {@link #setIndicatorSliderRadius(int,int)} instead
+     */
+    @Deprecated
+    public BannerViewPager<T, VH> setIndicatorRadius(int normalRadius, int checkedRadius) {
+        mBannerManager.bannerOptions().setIndicatorSliderWidth(normalRadius * 2, checkedRadius * 2);
+        return this;
+    }
+
+    /**
+     * set indicator circle radius
+     * <p>
+     * if the indicator style is {@link com.zhpan.indicator.enums.IndicatorStyle#DASH}
+     * or {@link com.zhpan.indicator.enums.IndicatorStyle#ROUND_RECT}
+     * the indicator dash width=2*radius
+     *
+     * @param radius 指示器圆点半径
+     * @deprecated use {@link #setIndicatorSliderRadius(int)} instead
+     */
+    @Deprecated
+    public BannerViewPager<T, VH> setIndicatorRadius(int radius) {
+        setIndicatorSliderRadius(radius, radius);
+        return this;
+    }
+
+
+    /**
+     * Set indicator dash width,if indicator style is {@link com.zhpan.indicator.enums.IndicatorStyle#CIRCLE},
+     * the indicator circle radius is indicatorWidth/2.
+     *
+     * @param indicatorWidth indicator dash width.
+     * @deprecated Use {@link #setIndicatorSliderWidth(int)} instead.
+     */
+    @Deprecated
+    public BannerViewPager<T, VH> setIndicatorWidth(int indicatorWidth) {
+        setIndicatorSliderWidth(indicatorWidth, indicatorWidth);
+        return this;
+    }
+
+
+    /**
+     *
+     * @deprecated Use {@link #setIndicatorSliderWidth(int,int)} instead.
+     */
+    @Deprecated
+    public BannerViewPager<T, VH> setIndicatorWidth(int normalWidth, int checkWidth) {
+        mBannerManager.bannerOptions().setIndicatorSliderWidth(normalWidth, checkWidth);
+        return this;
+    }
+
+    /**
+     * set indicator color
+     *
+     * @param checkedColor checked color of indicator
+     * @param normalColor  unchecked color of indicator
+     * @deprecated use {@link #setIndicatorSliderColor(int, int)} instead
+     */
+    @Deprecated
+    public BannerViewPager<T, VH> setIndicatorColor(@ColorInt int normalColor,
+                                                    @ColorInt int checkedColor) {
+        mBannerManager.bannerOptions().setIndicatorSliderColor(normalColor, checkedColor);
+        return this;
+    }
+
+
+    /**
+     * Set Indicator gap of dash/circle
+     *
+     * @param indicatorGap indicator gap
+     * @deprecated Use {@link #setIndicatorSliderGap(int)} instead.
+     */
+    public BannerViewPager<T, VH> setIndicatorGap(int indicatorGap) {
+        mBannerManager.bannerOptions().setIndicatorGap(indicatorGap);
+        return this;
+    }
+
+    /**
+     * @param showIndicator is show indicator
+     * @deprecated Use {@link #setIndicatorVisibility(int)} instead.
+     */
+    @Deprecated
+    public BannerViewPager<T, VH> showIndicator(boolean showIndicator) {
+        mIndicatorLayout.setVisibility(showIndicator ? VISIBLE : GONE);
+        return this;
+    }
 }

+ 1 - 1
bannerview/src/main/java/com/zhpan/bannerview/annotation/AIndicatorStyle.java

@@ -20,6 +20,6 @@ import static com.zhpan.bannerview.constants.IndicatorStyle.ROUND_RECT;
  */
 @IntDef({CIRCLE, DASH,ROUND_RECT})
 @Retention(RetentionPolicy.SOURCE)
-@Target(ElementType.PARAMETER)
+@Target({ElementType.PARAMETER,ElementType.FIELD})
 public @interface AIndicatorStyle {
 }

+ 84 - 48
bannerview/src/main/java/com/zhpan/bannerview/indicator/BaseIndicatorView.java

@@ -2,10 +2,15 @@ package com.zhpan.bannerview.indicator;
 
 import android.content.Context;
 import android.graphics.Paint;
+import android.support.annotation.ColorInt;
 import android.support.annotation.Nullable;
+import android.support.v4.view.ViewPager;
 import android.util.AttributeSet;
 import android.view.View;
 
+
+import com.zhpan.bannerview.annotation.AIndicatorSlideMode;
+import com.zhpan.bannerview.annotation.AIndicatorStyle;
 import com.zhpan.bannerview.constants.IndicatorSlideMode;
 import com.zhpan.bannerview.manager.IndicatorOptions;
 
@@ -21,6 +26,8 @@ public class BaseIndicatorView extends View implements IIndicator {
 
     protected Paint mPaint;
 
+    private ViewPager mViewPager;
+
     public BaseIndicatorView(Context context) {
         super(context);
     }
@@ -54,54 +61,90 @@ public class BaseIndicatorView extends View implements IIndicator {
     }
 
     private void scrollSlider(int position, float positionOffset) {
-        for (int i = 0; i < getPageSize(); i++) {
-            if (position % getPageSize() == getPageSize() - 1) { //   最后一个页面与第一个页面
-                if (positionOffset < 0.5) {
-                    setCurrentPosition(position);
-                    setSlideProgress(0);
-                } else {
-                    setCurrentPosition(0);
-                    setSlideProgress(0);
-                }
-            } else {    //  中间页面
+        if (position % getPageSize() == getPageSize() - 1) { //   最后一个页面与第一个页面
+            if (positionOffset < 0.5) {
                 setCurrentPosition(position);
-                setSlideProgress(positionOffset);
+                setSlideProgress(0);
+            } else {
+                setCurrentPosition(0);
+                setSlideProgress(0);
             }
+        } else {    //  中间页面
+            setCurrentPosition(position);
+            setSlideProgress(positionOffset);
         }
     }
 
-//    private boolean isSlideToRight(int position, float positionOffset) {
-//        int prePosition = mIndicatorOptions.getPrePosition();
-//        if ((prePosition == 0 && position == getPageSize() - 1)) {
-//            return false;
-//        } else if (prePosition == getPageSize() - 1 && position == 0) {
-//            return true;
-//        } else {
-//            return (position + positionOffset - prePosition) > 0;
-//        }
-//    }
 
     @Override
-    public void setPageSize(int pageSize) {
-        mIndicatorOptions.setPageSize(pageSize);
+    public void notifyDataChanged() {
+        setupViewPager();
         requestLayout();
+        invalidate();
+    }
+
+    private void setupViewPager() {
+        if (mViewPager != null) {
+            mViewPager.removeOnPageChangeListener(this);
+            mViewPager.addOnPageChangeListener(this);
+            if (mViewPager.getAdapter() != null)
+                setPageSize(mViewPager.getAdapter().getCount());
+        }
+    }
+
+    private void setPageSize(int pageSize) {
+        mIndicatorOptions.setPageSize(pageSize);
+    }
+
+    public BaseIndicatorView setSliderColor(@ColorInt int normalColor, @ColorInt int selectedColor) {
+        mIndicatorOptions.setSliderColor(normalColor, selectedColor);
+        return this;
+    }
+
+    public BaseIndicatorView setSliderWidth(float sliderWidth) {
+        mIndicatorOptions.setSliderWidth(sliderWidth);
+        return this;
+    }
+
+    public BaseIndicatorView setSliderWidth(float normalSliderWidth, float selectedSliderWidth) {
+        mIndicatorOptions.setSliderWidth(normalSliderWidth, selectedSliderWidth);
+        return this;
+    }
+
+    public BaseIndicatorView setSliderGap(float sliderGap) {
+        mIndicatorOptions.setSliderGap(sliderGap);
+        return this;
+    }
+
+    public BaseIndicatorView setSlideMode(@AIndicatorSlideMode int slideMode) {
+        mIndicatorOptions.setSlideMode(slideMode);
+        return this;
     }
 
+    public BaseIndicatorView setIndicatorStyle(@AIndicatorStyle int indicatorStyle) {
+        mIndicatorOptions.setIndicatorStyle(indicatorStyle);
+        return this;
+    }
+
+    public BaseIndicatorView setSliderHeight(float sliderHeight) {
+        mIndicatorOptions.setSliderHeight(sliderHeight);
+        return this;
+    }
 
     public int getPageSize() {
         return mIndicatorOptions.getPageSize();
     }
 
     public int getNormalColor() {
-        return mIndicatorOptions.getNormalColor();
+        return mIndicatorOptions.getNormalSliderColor();
     }
 
     public int getCheckedColor() {
-        return mIndicatorOptions.getCheckedColor();
+        return mIndicatorOptions.getCheckedSliderColor();
     }
 
     public float getIndicatorGap() {
-        return mIndicatorOptions.getIndicatorGap();
+        return mIndicatorOptions.getSliderGap();
     }
 
     public float getSlideProgress() {
@@ -112,41 +155,30 @@ public class BaseIndicatorView extends View implements IIndicator {
         return mIndicatorOptions.getCurrentPosition();
     }
 
-    public void setCurrentPosition(int currentPosition) {
-        mIndicatorOptions.setCurrentPosition(currentPosition);
-    }
-
-    public void setIndicatorOptions(IndicatorOptions indicatorOptions) {
-        mIndicatorOptions = indicatorOptions;
-    }
-
-//    public boolean isSlideToRight() {
-//        return mIndicatorOptions.isSlideToRight();
-//    }
-
     public int getSlideMode() {
         return mIndicatorOptions.getSlideMode();
     }
 
-    public float getNormalIndicatorWidth() {
-        return mIndicatorOptions.getNormalIndicatorWidth();
+    public float getNormalSliderWidth() {
+        return mIndicatorOptions.getNormalSliderWidth();
     }
 
-    public float getCheckedIndicatorWidth() {
-        return mIndicatorOptions.getCheckedIndicatorWidth();
+    public float getCheckedSliderWidth() {
+        return mIndicatorOptions.getCheckedSliderWidth();
     }
 
     private void setSlideProgress(float slideProgress) {
         mIndicatorOptions.setSlideProgress(slideProgress);
     }
 
-//    private void setPrePosition(int prePosition) {
-//        mIndicatorOptions.setPrePosition(prePosition);
-//    }
+    private void setCurrentPosition(int currentPosition) {
+        mIndicatorOptions.setCurrentPosition(currentPosition);
+    }
 
-//    private void setSlideToRight(boolean slideToRight) {
-//        mIndicatorOptions.setSlideToRight(slideToRight);
-//    }
+    public void setupWithViewPager(ViewPager viewPager) {
+        mViewPager = viewPager;
+        notifyDataChanged();
+    }
 
     public IndicatorOptions getIndicatorOptions() {
         return mIndicatorOptions;
@@ -155,4 +187,8 @@ public class BaseIndicatorView extends View implements IIndicator {
     @Override
     public void onPageScrollStateChanged(int state) {
     }
+
+    public void setIndicatorOptions(IndicatorOptions indicatorOptions) {
+        mIndicatorOptions = indicatorOptions;
+    }
 }

+ 8 - 5
bannerview/src/main/java/com/zhpan/bannerview/indicator/CircleIndicatorView.java

@@ -2,6 +2,7 @@ package com.zhpan.bannerview.indicator;
 
 import android.content.Context;
 import android.graphics.Canvas;
+import android.graphics.Paint;
 import android.util.AttributeSet;
 
 /**
@@ -16,6 +17,7 @@ public class CircleIndicatorView extends BaseIndicatorView {
     private float mCheckedRadius;
     private float maxRadius;
     private int height;
+    private Paint mPaint = new Paint();
 
     public CircleIndicatorView(Context context) {
         this(context, null);
@@ -27,10 +29,11 @@ public class CircleIndicatorView extends BaseIndicatorView {
 
     public CircleIndicatorView(Context context, AttributeSet attrs, int defStyleAttr) {
         super(context, attrs, defStyleAttr);
+        mPaint.setAntiAlias(true);
         mPaint.setColor(getNormalColor());
-        mNormalRadius = getNormalIndicatorWidth() / 2;
-        mCheckedRadius = getCheckedIndicatorWidth() / 2;
-        getIndicatorOptions().setIndicatorGap(mNormalRadius * 2);
+        mNormalRadius = getNormalSliderWidth() / 2;
+        mCheckedRadius = getCheckedSliderWidth() / 2;
+        getIndicatorOptions().setSliderGap(mNormalRadius * 2);
     }
 
     @Override
@@ -42,8 +45,8 @@ public class CircleIndicatorView extends BaseIndicatorView {
     @Override
     protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
         super.onMeasure(widthMeasureSpec, heightMeasureSpec);
-        mNormalRadius = getNormalIndicatorWidth() / 2;
-        mCheckedRadius = getCheckedIndicatorWidth() / 2;
+        mNormalRadius = getNormalSliderWidth() / 2;
+        mCheckedRadius = getCheckedSliderWidth() / 2;
         maxRadius = Math.max(mCheckedRadius, mNormalRadius);
         setMeasuredDimension((int) ((getPageSize() - 1) * getIndicatorGap() + 2 * (maxRadius + mNormalRadius * (getPageSize() - 1))),
                 (int) (2 * maxRadius));

+ 6 - 6
bannerview/src/main/java/com/zhpan/bannerview/indicator/DashIndicatorView.java

@@ -28,14 +28,14 @@ public class DashIndicatorView extends BaseIndicatorView {
     public DashIndicatorView(Context context, AttributeSet attrs, int defStyleAttr) {
         super(context, attrs, defStyleAttr);
         mPaint.setColor(getNormalColor());
-        sliderHeight = getNormalIndicatorWidth() / 2;
+        sliderHeight = getNormalSliderWidth() / 2;
     }
 
     @Override
     protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
         super.onMeasure(widthMeasureSpec, heightMeasureSpec);
-        maxWidth = Math.max(getNormalIndicatorWidth(), getCheckedIndicatorWidth());
-        minWidth = Math.min(getNormalIndicatorWidth(), getCheckedIndicatorWidth());
+        maxWidth = Math.max(getNormalSliderWidth(), getCheckedSliderWidth());
+        minWidth = Math.min(getNormalSliderWidth(), getCheckedSliderWidth());
         setMeasuredDimension((int) ((getPageSize() - 1) * getIndicatorGap() + maxWidth + (getPageSize() - 1) * minWidth),
                 (int) (getSliderHeight()));
     }
@@ -56,10 +56,10 @@ public class DashIndicatorView extends BaseIndicatorView {
 
 
     private void normalSlide(Canvas canvas, int i) {
-        if (getNormalIndicatorWidth() == getCheckedIndicatorWidth()) {
+        if (getNormalSliderWidth() == getCheckedSliderWidth()) {
             mPaint.setColor(getNormalColor());
-            float left = i * (getNormalIndicatorWidth()) + i * +getIndicatorGap();
-            canvas.drawRect(left, 0, left + getNormalIndicatorWidth(), getSliderHeight(), mPaint);
+            float left = i * (getNormalSliderWidth()) + i * +getIndicatorGap();
+            canvas.drawRect(left, 0, left + getNormalSliderWidth(), getSliderHeight(), mPaint);
             drawSliderStyle(canvas);
         } else {  //  仿支付宝首页轮播图的Indicator
             if (i < getCurrentPosition()) {

+ 2 - 2
bannerview/src/main/java/com/zhpan/bannerview/indicator/IIndicator.java

@@ -1,9 +1,9 @@
 package com.zhpan.bannerview.indicator;
 
 
+
 import android.support.v4.view.ViewPager;
 
-import com.zhpan.bannerview.annotation.AIndicatorSlideMode;
 import com.zhpan.bannerview.manager.IndicatorOptions;
 
 
@@ -15,7 +15,7 @@ import com.zhpan.bannerview.manager.IndicatorOptions;
  */
 public interface IIndicator extends ViewPager.OnPageChangeListener {
 
-    void setPageSize(int pageSize);
+    void notifyDataChanged();
 
     void setIndicatorOptions(IndicatorOptions options);
 }

+ 4 - 5
bannerview/src/main/java/com/zhpan/bannerview/indicator/drawer/BaseDrawer.java

@@ -28,10 +28,9 @@ public abstract class BaseDrawer implements IDrawer {
         mRectF = new RectF();
     }
 
-    @Override
     public MeasureResult onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
-        maxWidth = Math.max(mIndicatorOptions.getNormalIndicatorWidth(), mIndicatorOptions.getCheckedIndicatorWidth());
-        minWidth = Math.min(mIndicatorOptions.getNormalIndicatorWidth(), mIndicatorOptions.getCheckedIndicatorWidth());
+        maxWidth = Math.max(mIndicatorOptions.getNormalSliderWidth(), mIndicatorOptions.getCheckedSliderWidth());
+        minWidth = Math.min(mIndicatorOptions.getNormalSliderWidth(), mIndicatorOptions.getCheckedSliderWidth());
         mMeasureResult.setMeasureResult(measureWidth(), measureHeight());
         return mMeasureResult;
     }
@@ -42,7 +41,7 @@ public abstract class BaseDrawer implements IDrawer {
 
     private int measureWidth() {
         int pageSize = mIndicatorOptions.getPageSize();
-        float indicatorGap = mIndicatorOptions.getIndicatorGap();
+        float indicatorGap = mIndicatorOptions.getSliderGap();
         return (int) ((pageSize - 1) * indicatorGap + maxWidth + (pageSize - 1) * minWidth);
     }
 
@@ -73,6 +72,6 @@ public abstract class BaseDrawer implements IDrawer {
     }
 
     protected boolean isWidthEquals() {
-        return mIndicatorOptions.getNormalIndicatorWidth() == mIndicatorOptions.getCheckedIndicatorWidth();
+        return mIndicatorOptions.getNormalSliderWidth() == mIndicatorOptions.getCheckedSliderWidth();
     }
 }

+ 8 - 8
bannerview/src/main/java/com/zhpan/bannerview/indicator/drawer/CircleDrawer.java

@@ -38,8 +38,8 @@ public class CircleDrawer extends BaseDrawer {
     }
 
     private void drawNormal(Canvas canvas) {
-        float normalIndicatorWidth = mIndicatorOptions.getNormalIndicatorWidth();
-        mPaint.setColor(mIndicatorOptions.getNormalColor());
+        float normalIndicatorWidth = mIndicatorOptions.getNormalSliderWidth();
+        mPaint.setColor(mIndicatorOptions.getNormalSliderColor());
         for (int i = 0; i < mIndicatorOptions.getPageSize(); i++) {
             float coordinateX = BannerUtils.getCoordinateX(mIndicatorOptions, maxWidth, i);
             float coordinateY = BannerUtils.getCoordinateY(maxWidth);
@@ -48,14 +48,14 @@ public class CircleDrawer extends BaseDrawer {
     }
 
     private void drawSlider(Canvas canvas) {
-        mPaint.setColor(mIndicatorOptions.getCheckedColor());
+        mPaint.setColor(mIndicatorOptions.getCheckedSliderColor());
         switch (mIndicatorOptions.getSlideMode()) {
             case NORMAL:
             case SMOOTH:
                 drawCircleSlider(canvas);
                 break;
             case WORM:
-                drawWormSlider(canvas, mIndicatorOptions.getNormalIndicatorWidth());
+                drawWormSlider(canvas, mIndicatorOptions.getNormalSliderWidth());
                 break;
         }
     }
@@ -66,17 +66,17 @@ public class CircleDrawer extends BaseDrawer {
         float endCoordinateX = BannerUtils.getCoordinateX(mIndicatorOptions, maxWidth, (currentPosition + 1) % mIndicatorOptions.getPageSize());
         float coordinateX = startCoordinateX + (endCoordinateX - startCoordinateX) * mIndicatorOptions.getSlideProgress();
         float coordinateY = BannerUtils.getCoordinateY(maxWidth);
-        float radius = mIndicatorOptions.getCheckedIndicatorWidth() / 2;
+        float radius = mIndicatorOptions.getCheckedSliderWidth() / 2;
         drawCircle(canvas, coordinateX, coordinateY, radius);
     }
 
     private void drawWormSlider(Canvas canvas, float sliderHeight) {
         float slideProgress = mIndicatorOptions.getSlideProgress();
         int currentPosition = mIndicatorOptions.getCurrentPosition();
-        float distance = mIndicatorOptions.getIndicatorGap() + mIndicatorOptions.getNormalIndicatorWidth();
+        float distance = mIndicatorOptions.getSliderGap() + mIndicatorOptions.getNormalSliderWidth();
         float startCoordinateX = BannerUtils.getCoordinateX(mIndicatorOptions, maxWidth, currentPosition);
-        float left = startCoordinateX + Math.max(distance * (slideProgress - 0.5f) * 2.0f, 0) - mIndicatorOptions.getNormalIndicatorWidth() / 2;
-        float right = startCoordinateX + Math.min((distance * slideProgress * 2), distance) + mIndicatorOptions.getNormalIndicatorWidth() / 2;
+        float left = startCoordinateX + Math.max(distance * (slideProgress - 0.5f) * 2.0f, 0) - mIndicatorOptions.getNormalSliderWidth() / 2;
+        float right = startCoordinateX + Math.min((distance * slideProgress * 2), distance) + mIndicatorOptions.getNormalSliderWidth() / 2;
         rectF.set(left, 0, right, sliderHeight);
         canvas.drawRoundRect(rectF, sliderHeight, sliderHeight, mPaint);
     }

+ 10 - 10
bannerview/src/main/java/com/zhpan/bannerview/indicator/drawer/RectDrawer.java

@@ -35,17 +35,17 @@ public class RectDrawer extends BaseDrawer {
 
     private void drawUncheckedSlider(Canvas canvas, int pageSize) {
         for (int i = 0; i < pageSize; i++) {
-            mPaint.setColor(mIndicatorOptions.getNormalColor());
+            mPaint.setColor(mIndicatorOptions.getNormalSliderColor());
             float sliderHeight = mIndicatorOptions.getSliderHeight();
-            float left = i * (maxWidth) + i * +mIndicatorOptions.getIndicatorGap() + (maxWidth - minWidth);
+            float left = i * (maxWidth) + i * +mIndicatorOptions.getSliderGap() + (maxWidth - minWidth);
             mRectF.set(left, 0, left + minWidth, sliderHeight);
             drawRoundRect(canvas, sliderHeight, sliderHeight);
         }
     }
 
     private void drawInequalitySlider(Canvas canvas, int i) {
-        int normalColor = mIndicatorOptions.getNormalColor();
-        float indicatorGap = mIndicatorOptions.getIndicatorGap();
+        int normalColor = mIndicatorOptions.getNormalSliderColor();
+        float indicatorGap = mIndicatorOptions.getSliderGap();
         float sliderHeight = mIndicatorOptions.getSliderHeight();
         int currentPosition = mIndicatorOptions.getCurrentPosition();
         if (i < currentPosition) {
@@ -54,7 +54,7 @@ public class RectDrawer extends BaseDrawer {
             mRectF.set(left, 0, left + minWidth, sliderHeight);
             drawRoundRect(canvas, sliderHeight, sliderHeight);
         } else if (i == currentPosition) {
-            mPaint.setColor(mIndicatorOptions.getCheckedColor());
+            mPaint.setColor(mIndicatorOptions.getCheckedSliderColor());
             float left = i * minWidth + i * indicatorGap;
             mRectF.set(left, 0, left + minWidth + (maxWidth - minWidth), sliderHeight);
             drawRoundRect(canvas, sliderHeight, sliderHeight);
@@ -67,7 +67,7 @@ public class RectDrawer extends BaseDrawer {
     }
 
     private void drawCheckedSlider(Canvas canvas) {
-        mPaint.setColor(mIndicatorOptions.getCheckedColor());
+        mPaint.setColor(mIndicatorOptions.getCheckedSliderColor());
         switch (mIndicatorOptions.getSlideMode()) {
             case IndicatorSlideMode.SMOOTH:
                 drawSmoothSlider(canvas);
@@ -82,17 +82,17 @@ public class RectDrawer extends BaseDrawer {
         float sliderHeight = mIndicatorOptions.getSliderHeight();
         float slideProgress = mIndicatorOptions.getSlideProgress();
         int currentPosition = mIndicatorOptions.getCurrentPosition();
-        float distance = mIndicatorOptions.getIndicatorGap() + mIndicatorOptions.getNormalIndicatorWidth();
+        float distance = mIndicatorOptions.getSliderGap() + mIndicatorOptions.getNormalSliderWidth();
         float startCoordinateX = BannerUtils.getCoordinateX(mIndicatorOptions, maxWidth, currentPosition);
-        float left = startCoordinateX + Math.max(distance * (slideProgress - 0.5f) * 2.0f, 0) - mIndicatorOptions.getNormalIndicatorWidth() / 2;
-        float right = startCoordinateX + Math.min((distance * slideProgress * 2), distance) + mIndicatorOptions.getNormalIndicatorWidth() / 2;
+        float left = startCoordinateX + Math.max(distance * (slideProgress - 0.5f) * 2.0f, 0) - mIndicatorOptions.getNormalSliderWidth() / 2;
+        float right = startCoordinateX + Math.min((distance * slideProgress * 2), distance) + mIndicatorOptions.getNormalSliderWidth() / 2;
         mRectF.set(left, 0, right, sliderHeight);
         drawRoundRect(canvas, sliderHeight, sliderHeight);
     }
 
     private void drawSmoothSlider(Canvas canvas) {
         int currentPosition = mIndicatorOptions.getCurrentPosition();
-        float indicatorGap = mIndicatorOptions.getIndicatorGap();
+        float indicatorGap = mIndicatorOptions.getSliderGap();
         float sliderHeight = mIndicatorOptions.getSliderHeight();
         float left = currentPosition * (maxWidth) + currentPosition * +indicatorGap + (maxWidth + indicatorGap) * mIndicatorOptions.getSlideProgress();
         mRectF.set(left, 0, left + maxWidth, sliderHeight);

+ 2 - 4
bannerview/src/main/java/com/zhpan/bannerview/manager/AttributeController.java

@@ -44,16 +44,14 @@ public class AttributeController {
         int indicatorStyle = typedArray.getInt(R.styleable.BannerViewPager_bvp_indicator_style, 0);
         int indicatorSlideMode = typedArray.getInt(R.styleable.BannerViewPager_bvp_indicator_slide_mode, 0);
         int indicatorVisibility = typedArray.getInt(R.styleable.BannerViewPager_bvp_indicator_visibility, 0);
-        mBannerOptions.setIndicatorCheckedColor(indicatorCheckedColor);
-        mBannerOptions.setIndicatorNormalColor(indicatorNormalColor);
-        mBannerOptions.setNormalIndicatorWidth(normalIndicatorWidth);
+        mBannerOptions.setIndicatorSliderColor(indicatorNormalColor,indicatorCheckedColor);
+        mBannerOptions.setIndicatorSliderWidth(normalIndicatorWidth,normalIndicatorWidth);
         mBannerOptions.setIndicatorGravity(indicatorGravity);
         mBannerOptions.setIndicatorStyle(indicatorStyle);
         mBannerOptions.setIndicatorSlideMode(indicatorSlideMode);
         mBannerOptions.setIndicatorVisibility(indicatorVisibility);
         mBannerOptions.setIndicatorGap(normalIndicatorWidth);
         mBannerOptions.setIndicatorHeight(normalIndicatorWidth / 2);
-        mBannerOptions.setCheckedIndicatorWidth(normalIndicatorWidth);
     }
 
     private void initBannerAttrs(TypedArray typedArray) {

+ 13 - 19
bannerview/src/main/java/com/zhpan/bannerview/manager/BannerOptions.java

@@ -100,36 +100,30 @@ public class BannerOptions {
     }
 
     public int getIndicatorNormalColor() {
-        return mIndicatorOptions.getNormalColor();
-    }
-
-    public void setIndicatorNormalColor(int indicatorNormalColor) {
-        mIndicatorOptions.setNormalColor(indicatorNormalColor);
+        return mIndicatorOptions.getNormalSliderColor();
     }
 
     public int getIndicatorCheckedColor() {
-        return mIndicatorOptions.getCheckedColor();
-    }
-
-    public void setIndicatorCheckedColor(int indicatorCheckedColor) {
-        mIndicatorOptions.setCheckedColor(indicatorCheckedColor);
+        return mIndicatorOptions.getCheckedSliderColor();
     }
 
     public int getNormalIndicatorWidth() {
-        return (int) mIndicatorOptions.getNormalIndicatorWidth();
+        return (int) mIndicatorOptions.getNormalSliderWidth();
     }
 
-    public void setNormalIndicatorWidth(int normalIndicatorWidth) {
-        mIndicatorOptions.setNormalIndicatorWidth(normalIndicatorWidth);
+
+
+    public void setIndicatorSliderColor(int normalColor,int checkedColor){
+        mIndicatorOptions.setSliderColor(normalColor,checkedColor);
     }
 
+    public void setIndicatorSliderWidth(int normalWidth,int checkedWidth){
+        mIndicatorOptions.setSliderWidth(normalWidth,checkedWidth);
+    }
     public int getCheckedIndicatorWidth() {
-        return (int) mIndicatorOptions.getCheckedIndicatorWidth();
+        return (int) mIndicatorOptions.getCheckedSliderWidth();
     }
 
-    public void setCheckedIndicatorWidth(int checkedIndicatorWidth) {
-        mIndicatorOptions.setCheckedIndicatorWidth(checkedIndicatorWidth);
-    }
 
     public IndicatorOptions getIndicatorOptions() {
         return mIndicatorOptions;
@@ -168,11 +162,11 @@ public class BannerOptions {
     }
 
     public float getIndicatorGap() {
-        return mIndicatorOptions.getIndicatorGap();
+        return mIndicatorOptions.getSliderGap();
     }
 
     public void setIndicatorGap(float indicatorGap) {
-        mIndicatorOptions.setIndicatorGap(indicatorGap);
+        mIndicatorOptions.setSliderGap(indicatorGap);
     }
 
     public float getIndicatorHeight() {

+ 55 - 70
bannerview/src/main/java/com/zhpan/bannerview/manager/IndicatorOptions.java

@@ -2,6 +2,8 @@ package com.zhpan.bannerview.manager;
 
 import android.graphics.Color;
 
+import com.zhpan.bannerview.annotation.AIndicatorSlideMode;
+import com.zhpan.bannerview.annotation.AIndicatorStyle;
 import com.zhpan.bannerview.constants.IndicatorSlideMode;
 import com.zhpan.bannerview.utils.BannerUtils;
 
@@ -14,15 +16,25 @@ import com.zhpan.bannerview.utils.BannerUtils;
 public class IndicatorOptions {
 
     public IndicatorOptions() {
-        normalIndicatorWidth = BannerUtils.dp2px(8);
-        checkedIndicatorWidth = normalIndicatorWidth;
-        indicatorGap = normalIndicatorWidth;
+        normalSliderWidth = BannerUtils.dp2px(8);
+        checkedSliderWidth = normalSliderWidth;
+        sliderGap = normalSliderWidth;
         normalColor = Color.parseColor("#8C18171C");
         checkedColor = Color.parseColor("#8C6C6D72");
         slideMode = IndicatorSlideMode.NORMAL;
     }
 
-    private int mIndicatorStyle;
+    private @AIndicatorStyle
+    int mIndicatorStyle;
+
+    /**
+     * Indicator滑动模式,目前仅支持两种
+     *
+     * @see IndicatorSlideMode#NORMAL
+     * @see IndicatorSlideMode#SMOOTH
+     */
+    private @AIndicatorSlideMode
+    int slideMode;
 
     /**
      * 页面size
@@ -39,55 +51,33 @@ public class IndicatorOptions {
     /**
      * Indicator间距
      */
-    private float indicatorGap;
-    /**
-     * 从一个点滑动到另一个点的进度
-     */
-    private float slideProgress;
+    private float sliderGap;
+
+    private float sliderHeight;
+
+    private float normalSliderWidth;
+
+    private float checkedSliderWidth;
+
     /**
      * 指示器当前位置
      */
     private int currentPosition;
-//    /**
-//     * 指示器上一个位置
-//     */
-//    private int prePosition;
-//    /**
-//     * 是否是向右滑动,true向右,false向左
-//     */
-//    private boolean slideToRight;
-
-    private float sliderHeight;
 
     /**
-     * Indicator滑动模式,目前仅支持两种
-     *
-     * @see IndicatorSlideMode#NORMAL
-     * @see IndicatorSlideMode#SMOOTH
+     * 从一个点滑动到另一个点的进度
      */
-    private int slideMode;
-
-    private float normalIndicatorWidth;
-
-    private float checkedIndicatorWidth;
+    private float slideProgress;
 
     public int getPageSize() {
         return pageSize;
     }
 
-    public void setPageSize(int pageSize) {
-        this.pageSize = pageSize;
-    }
-
-    public int getNormalColor() {
+    public int getNormalSliderColor() {
         return normalColor;
     }
 
-    public void setNormalColor(int normalColor) {
-        this.normalColor = normalColor;
-    }
-
-    public int getCheckedColor() {
+    public int getCheckedSliderColor() {
         return checkedColor;
     }
 
@@ -95,12 +85,12 @@ public class IndicatorOptions {
         this.checkedColor = checkedColor;
     }
 
-    public float getIndicatorGap() {
-        return indicatorGap;
+    public float getSliderGap() {
+        return sliderGap;
     }
 
-    public void setIndicatorGap(float indicatorGap) {
-        this.indicatorGap = indicatorGap;
+    public void setSliderGap(float sliderGap) {
+        this.sliderGap = sliderGap;
     }
 
     public float getSlideProgress() {
@@ -119,22 +109,6 @@ public class IndicatorOptions {
         this.currentPosition = currentPosition;
     }
 
-//    public int getPrePosition() {
-//        return prePosition;
-//    }
-
-//    public void setPrePosition(int prePosition) {
-//        this.prePosition = prePosition;
-//    }
-
-//    public boolean isSlideToRight() {
-//        return slideToRight;
-//    }
-
-//    public void setSlideToRight(boolean slideToRight) {
-//        this.slideToRight = slideToRight;
-//    }
-
     public int getSlideMode() {
         return slideMode;
     }
@@ -143,24 +117,17 @@ public class IndicatorOptions {
         this.slideMode = slideMode;
     }
 
-    public float getNormalIndicatorWidth() {
-        return normalIndicatorWidth;
-    }
-
-    public void setNormalIndicatorWidth(float normalIndicatorWidth) {
-        this.normalIndicatorWidth = normalIndicatorWidth;
+    public float getNormalSliderWidth() {
+        return normalSliderWidth;
     }
 
-    public float getCheckedIndicatorWidth() {
-        return checkedIndicatorWidth;
+    public float getCheckedSliderWidth() {
+        return checkedSliderWidth;
     }
 
-    public void setCheckedIndicatorWidth(float checkedIndicatorWidth) {
-        this.checkedIndicatorWidth = checkedIndicatorWidth;
-    }
 
     public float getSliderHeight() {
-        return sliderHeight > 0 ? sliderHeight : normalIndicatorWidth / 2;
+        return sliderHeight > 0 ? sliderHeight : normalSliderWidth / 2;
     }
 
     public void setSliderHeight(float sliderHeight) {
@@ -171,7 +138,25 @@ public class IndicatorOptions {
         return mIndicatorStyle;
     }
 
+    public void setPageSize(int pageSize) {
+        this.pageSize = pageSize;
+    }
+
     public void setIndicatorStyle(int indicatorStyle) {
         mIndicatorStyle = indicatorStyle;
     }
+
+    public void setSliderWidth(float normalIndicatorWidth, float checkedIndicatorWidth) {
+        this.normalSliderWidth = normalIndicatorWidth;
+        this.checkedSliderWidth = checkedIndicatorWidth;
+    }
+
+    public void setSliderWidth(float sliderWidth) {
+        setSliderWidth(sliderWidth, sliderWidth);
+    }
+
+    public void setSliderColor(int normalColor, int checkedColor) {
+        this.normalColor = normalColor;
+        this.checkedColor = checkedColor;
+    }
 }

+ 2 - 2
bannerview/src/main/java/com/zhpan/bannerview/utils/BannerUtils.java

@@ -44,8 +44,8 @@ public class BannerUtils {
     }
 
     public static float getCoordinateX(IndicatorOptions indicatorOptions, float maxDiameter, int index) {
-        float normalIndicatorWidth = indicatorOptions.getNormalIndicatorWidth();
-        return maxDiameter / 2 + (normalIndicatorWidth + indicatorOptions.getIndicatorGap()) * index;
+        float normalIndicatorWidth = indicatorOptions.getNormalSliderWidth();
+        return maxDiameter / 2 + (normalIndicatorWidth + indicatorOptions.getSliderGap()) * index;
     }
 
     public static float getCoordinateY(float maxDiameter) {