From 31a626abb920d4117209f13830096c77e55804e9 Mon Sep 17 00:00:00 2001 From: Ztiany Date: Fri, 25 Oct 2019 16:26:50 +0800 Subject: [PATCH] fix BannerView bugs --- .../base/imageloader/ProgressGlideModule.java | 9 +++++++-- .../base/utils/android/ActFragWrapper.java | 3 +++ .../base/widget/viewpager/BannerViewPager.java | 18 ++++++++++++++---- .../android/sdk/mediaselector/CropOptions.java | 1 - 4 files changed, 24 insertions(+), 7 deletions(-) diff --git a/lib_base/src/main/java/com/android/base/imageloader/ProgressGlideModule.java b/lib_base/src/main/java/com/android/base/imageloader/ProgressGlideModule.java index b0695c2..301b074 100644 --- a/lib_base/src/main/java/com/android/base/imageloader/ProgressGlideModule.java +++ b/lib_base/src/main/java/com/android/base/imageloader/ProgressGlideModule.java @@ -16,21 +16,26 @@ import okhttp3.OkHttpClient; public class ProgressGlideModule extends AppGlideModule { + //配置glide网络加载框架 @Override @CallSuper public void registerComponents(@NonNull Context context, @NonNull Glide glide, @NonNull Registry registry) { - //配置glide网络加载框架 ProgressManager.getInstance().setRefreshTime(getRefreshTime()); OkHttpClient.Builder builder = ProgressManager.getInstance().withProgress(new OkHttpClient.Builder()); + configImageOkHttp(builder); registry.replace(GlideUrl.class, InputStream.class, new OkHttpUrlLoader.Factory(builder.build())); } + //不使用清单配置的方式,减少初始化时间 @Override public boolean isManifestParsingEnabled() { - //不使用清单配置的方式,减少初始化时间 return false; } + protected void configImageOkHttp(OkHttpClient.Builder builder) { + + } + protected int getRefreshTime() { return 200; } diff --git a/lib_base/src/main/java/com/android/base/utils/android/ActFragWrapper.java b/lib_base/src/main/java/com/android/base/utils/android/ActFragWrapper.java index 8706c09..a04a55a 100644 --- a/lib_base/src/main/java/com/android/base/utils/android/ActFragWrapper.java +++ b/lib_base/src/main/java/com/android/base/utils/android/ActFragWrapper.java @@ -18,6 +18,9 @@ public class ActFragWrapper { private Fragment mFragment; private Activity mActivity; + private ActFragWrapper() { + } + public static ActFragWrapper create(Activity activity) { ActFragWrapper context = new ActFragWrapper(); context.mActivity = activity; diff --git a/lib_base/src/main/java/com/android/base/widget/viewpager/BannerViewPager.java b/lib_base/src/main/java/com/android/base/widget/viewpager/BannerViewPager.java index 6f376e6..d3b1971 100644 --- a/lib_base/src/main/java/com/android/base/widget/viewpager/BannerViewPager.java +++ b/lib_base/src/main/java/com/android/base/widget/viewpager/BannerViewPager.java @@ -109,11 +109,21 @@ public class BannerViewPager extends FrameLayout { } public void setCurrentPosition(int position) { + if (position < 0) { + return; + } if (mImageUrlList.size() > 1) { - if (position <= mImageUrlList.size() - 2) { - position++; - } else { - position = mImageUrlList.size() - 2; + int realSize = mImageUrlList.size() - 2; + if (position >= realSize) { + position = realSize - 1; + } + if (mOnBannerPositionChangedListener != null) { + mOnBannerPositionChangedListener.onPagePositionChanged(position); + } + position++; + } else { + if (mOnBannerPositionChangedListener != null) { + mOnBannerPositionChangedListener.onPagePositionChanged(0); } } mViewPager.setCurrentItem(position); diff --git a/lib_media_selector/src/main/java/com/android/sdk/mediaselector/CropOptions.java b/lib_media_selector/src/main/java/com/android/sdk/mediaselector/CropOptions.java index 6606e7d..46ba179 100644 --- a/lib_media_selector/src/main/java/com/android/sdk/mediaselector/CropOptions.java +++ b/lib_media_selector/src/main/java/com/android/sdk/mediaselector/CropOptions.java @@ -16,7 +16,6 @@ public class CropOptions implements Serializable { private int outputY; public CropOptions() { - } int getAspectX() {