Skip to content

Commit 9ddda6d

Browse files
committed
Update for issue #280,set auto play smoothly supported.
1 parent 188ab74 commit 9ddda6d

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

bannerview/src/main/java/com/zhpan/bannerview/BannerViewPager.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,8 @@ private void pageScrolled(int position, float positionOffset, int positionOffset
298298

299299
private void handlePosition() {
300300
if (mBannerPagerAdapter != null && mBannerPagerAdapter.getListSize() > 1 && isAutoPlay()) {
301-
mViewPager.setCurrentItem(mViewPager.getCurrentItem() + 1);
301+
mViewPager.setCurrentItem(mViewPager.getCurrentItem() + 1,
302+
mBannerManager.getBannerOptions().isAutoScrollSmoothly());
302303
mHandler.postDelayed(mRunnable, getInterval());
303304
}
304305
}
@@ -1141,6 +1142,15 @@ public BannerViewPager<T> showIndicatorWhenOneItem(boolean showIndicatorWhenOneI
11411142
return this;
11421143
}
11431144

1145+
/**
1146+
* @param autoScrollSmoothly is auto play scroll smoothly.
1147+
*/
1148+
public BannerViewPager<T> setAutoPlaySmoothly(boolean autoScrollSmoothly) {
1149+
mBannerManager.getBannerOptions()
1150+
.setAutoScrollSmoothly(autoScrollSmoothly);
1151+
return this;
1152+
}
1153+
11441154
/**
11451155
* @deprecated Use {@link BannerViewPager#disallowParentInterceptDownEvent(boolean)} instead.
11461156
*/

bannerview/src/main/java/com/zhpan/bannerview/manager/BannerOptions.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ public BannerOptions() {
8585

8686
private boolean stopLoopWhenDetachedFromWindow = true;
8787

88+
private boolean autoScrollSmoothly = true;
89+
8890
private final IndicatorOptions mIndicatorOptions;
8991

9092
public int getInterval() {
@@ -231,6 +233,14 @@ public void setIndicatorMargin(int left, int top, int right, int bottom) {
231233
mIndicatorMargin = new IndicatorMargin(left, top, right, bottom);
232234
}
233235

236+
public boolean isAutoScrollSmoothly() {
237+
return autoScrollSmoothly;
238+
}
239+
240+
public void setAutoScrollSmoothly(boolean autoScrollSmoothly) {
241+
this.autoScrollSmoothly = autoScrollSmoothly;
242+
}
243+
234244
public float[] getRoundRectRadiusArray() {
235245
return roundRadiusArray;
236246
}

0 commit comments

Comments
 (0)