Skip to content

Commit

Permalink
optimize
Browse files Browse the repository at this point in the history
  • Loading branch information
lightSky committed Nov 4, 2016
1 parent cc934cf commit 4d999bf
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 12 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 4d999bf

Please sign in to comment.