From 9ddda6dd7dbea14bd37c4bbb4ae08bfd0d76496f Mon Sep 17 00:00:00 2001 From: zhpanvip Date: Sat, 10 Sep 2022 15:22:03 +0800 Subject: [PATCH] Update for issue #280,set auto play smoothly supported. --- .../java/com/zhpan/bannerview/BannerViewPager.java | 12 +++++++++++- .../com/zhpan/bannerview/manager/BannerOptions.java | 10 ++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/bannerview/src/main/java/com/zhpan/bannerview/BannerViewPager.java b/bannerview/src/main/java/com/zhpan/bannerview/BannerViewPager.java index 7826ea8..d04dcc7 100644 --- a/bannerview/src/main/java/com/zhpan/bannerview/BannerViewPager.java +++ b/bannerview/src/main/java/com/zhpan/bannerview/BannerViewPager.java @@ -298,7 +298,8 @@ private void pageScrolled(int position, float positionOffset, int positionOffset private void handlePosition() { if (mBannerPagerAdapter != null && mBannerPagerAdapter.getListSize() > 1 && isAutoPlay()) { - mViewPager.setCurrentItem(mViewPager.getCurrentItem() + 1); + mViewPager.setCurrentItem(mViewPager.getCurrentItem() + 1, + mBannerManager.getBannerOptions().isAutoScrollSmoothly()); mHandler.postDelayed(mRunnable, getInterval()); } } @@ -1141,6 +1142,15 @@ public BannerViewPager showIndicatorWhenOneItem(boolean showIndicatorWhenOneI return this; } + /** + * @param autoScrollSmoothly is auto play scroll smoothly. + */ + public BannerViewPager setAutoPlaySmoothly(boolean autoScrollSmoothly) { + mBannerManager.getBannerOptions() + .setAutoScrollSmoothly(autoScrollSmoothly); + return this; + } + /** * @deprecated Use {@link BannerViewPager#disallowParentInterceptDownEvent(boolean)} instead. */ diff --git a/bannerview/src/main/java/com/zhpan/bannerview/manager/BannerOptions.java b/bannerview/src/main/java/com/zhpan/bannerview/manager/BannerOptions.java index ecbadf7..70c6faa 100644 --- a/bannerview/src/main/java/com/zhpan/bannerview/manager/BannerOptions.java +++ b/bannerview/src/main/java/com/zhpan/bannerview/manager/BannerOptions.java @@ -85,6 +85,8 @@ public BannerOptions() { private boolean stopLoopWhenDetachedFromWindow = true; + private boolean autoScrollSmoothly = true; + private final IndicatorOptions mIndicatorOptions; public int getInterval() { @@ -231,6 +233,14 @@ public void setIndicatorMargin(int left, int top, int right, int bottom) { mIndicatorMargin = new IndicatorMargin(left, top, right, bottom); } + public boolean isAutoScrollSmoothly() { + return autoScrollSmoothly; + } + + public void setAutoScrollSmoothly(boolean autoScrollSmoothly) { + this.autoScrollSmoothly = autoScrollSmoothly; + } + public float[] getRoundRectRadiusArray() { return roundRadiusArray; }