diff --git a/README.md b/README.md index c5895a9..48249a5 100644 --- a/README.md +++ b/README.md @@ -12,19 +12,19 @@ view recycle adapter.It contains two style.One is CircleIndicator seperated from ## Setting -You can config all feature in the `IndicatorConfiguration` class.It's build design pattern. +You can config all feature in the `IndicatorConfiguration` class.It adopt builder design pattern. - `interval(long)` set interval time of scroll in milliseconds, default is `DEFAULT_INTERVAL`. - `direction(int)` set auto scroll direction, default is `RIGHT`. -- `isLoop(boolean)` set whether still scroll when scroll to the end page. +- `isLoop(boolean)` set whether still scroll when scroll to the end page,default is true - `isDrawIndicator(boolean)` whether draw indicator,default is true. - `isAutoScroll(boolean)` whether start scroll while notiyDataChange. - `scrollDurationFactor(double)` set the factor of scroll duration - `isStopWhenTouch(boolean)` whether stop scroll while touching, default is true. - `position` set the position of indicator.You can reference `IndicatorConfiguration.IndicatorPosition` enum +- `pageResId` set custome page layout,if your page has imageview and want change it by res,you the id of imageview must is `slider_image` and you sholud provide a iamgeLoader - `imageLoader(ImageLoader)` set the loader engine to load image while page sliding.You can use any image loader library you what,there are several imageloader of Glide ,Picasso and UIL,decide how to load image,is absolutely free. -- `pageResId` set custome page layout,if your page has imageview and you want change it by res,you the id of imageview must is `slider_image` - `onPageChangeListener` set click listener to page diff --git a/demo/src/main/java/cn/lightsky/infiniteindicator/AnimIndicatorActivity.java b/demo/src/main/java/cn/lightsky/infiniteindicator/AnimIndicatorActivity.java index b424952..42e4c83 100644 --- a/demo/src/main/java/cn/lightsky/infiniteindicator/AnimIndicatorActivity.java +++ b/demo/src/main/java/cn/lightsky/infiniteindicator/AnimIndicatorActivity.java @@ -80,7 +80,7 @@ private void testAnimCircleIndicator() { mAnimCircleIndicator = (InfiniteIndicator) findViewById(R.id.infinite_anim_circle); IndicatorConfiguration configuration = new IndicatorConfiguration.Builder() .imageLoader(new UILoader()) - .isStopWhenTouch(true) + .isStopWhileTouch(true) .onPageChangeListener(this) .onPageClickListener(this) .direction(LEFT) @@ -96,7 +96,7 @@ private void testAnimLineIndicator() { IndicatorConfiguration configuration = new IndicatorConfiguration.Builder() .imageLoader(new PicassoLoader()) .isAutoScroll(false) - .isStopWhenTouch(true) + .isStopWhileTouch(true) .onPageChangeListener(this) .position(IndicatorConfiguration.IndicatorPosition.Center) .build(); diff --git a/library/src/main/java/cn/lightsky/infiniteindicator/IndicatorConfiguration.java b/library/src/main/java/cn/lightsky/infiniteindicator/IndicatorConfiguration.java index 68dc91c..02569b4 100644 --- a/library/src/main/java/cn/lightsky/infiniteindicator/IndicatorConfiguration.java +++ b/library/src/main/java/cn/lightsky/infiniteindicator/IndicatorConfiguration.java @@ -11,7 +11,7 @@ public class IndicatorConfiguration { public static final int DEFAULT_INTERVAL = 2500; - public static final double DEFAULT_SCROLL_FACTOR = 1.2; + public static final double DEFAULT_SCROLL_FACTOR = 1; public static final int LEFT = 0; public static final int RIGHT = 1; @@ -67,7 +67,7 @@ private IndicatorConfiguration(Builder builder) { presentIndicator = builder.indicatorPosition; indicator = builder.indicator; mOnPageClickListener = builder.onPageClickListener; - isStopScrollWhenTouch = builder.isStopScrollWhenTouch; + isStopScrollWhenTouch = builder.isStopWhileTouch; onPageChangeListener = builder.onPageChangeListener; } @@ -127,7 +127,7 @@ public static class Builder{ private double scrollFactor = DEFAULT_SCROLL_FACTOR; private boolean isLoop = true; private boolean isAutoScroll = true; - private boolean isStopScrollWhenTouch = true; + private boolean isStopWhileTouch = true; private boolean isDrawIndicator = true; private View indicator; private OnPageClickListener onPageClickListener; @@ -174,10 +174,10 @@ public Builder internal(long interval) { } /** - * whether stop auto scroll when touching, default is true * + * whether stop auto scroll while touching, default is true * */ - public Builder isStopWhenTouch(boolean isStopScrollWhenTouch) { - this.isStopScrollWhenTouch = isStopScrollWhenTouch; + public Builder isStopWhileTouch(boolean isStopScrollWhenTouch) { + this.isStopWhileTouch = isStopScrollWhenTouch; return this; } @@ -230,6 +230,11 @@ private Builder indicator(View indicator) { return this; } + /** + * set page change listener + * @param onPageChangeListener + * @return + */ public Builder onPageChangeListener(ViewPager.OnPageChangeListener onPageChangeListener) { this.onPageChangeListener = onPageChangeListener; return this; diff --git a/library/src/main/java/cn/lightsky/infiniteindicator/recycle/RecyleAdapter.java b/library/src/main/java/cn/lightsky/infiniteindicator/recycle/RecyleAdapter.java index f9d5cc6..361af56 100644 --- a/library/src/main/java/cn/lightsky/infiniteindicator/recycle/RecyleAdapter.java +++ b/library/src/main/java/cn/lightsky/infiniteindicator/recycle/RecyleAdapter.java @@ -87,7 +87,9 @@ public void onClick(View v) { }); } - mImageLoader.load(mContext, holder.target, page.res); + if (mImageLoader != null) { + mImageLoader.load(mContext, holder.target, page.res); + } } return convertView;