fix BannerView bugs

androidx
Ztiany 5 years ago
parent fb8c8c90d5
commit 31a626abb9
  1. 9
      lib_base/src/main/java/com/android/base/imageloader/ProgressGlideModule.java
  2. 3
      lib_base/src/main/java/com/android/base/utils/android/ActFragWrapper.java
  3. 14
      lib_base/src/main/java/com/android/base/widget/viewpager/BannerViewPager.java
  4. 1
      lib_media_selector/src/main/java/com/android/sdk/mediaselector/CropOptions.java

@ -16,21 +16,26 @@ import okhttp3.OkHttpClient;
public class ProgressGlideModule extends AppGlideModule { public class ProgressGlideModule extends AppGlideModule {
//配置glide网络加载框架
@Override @Override
@CallSuper @CallSuper
public void registerComponents(@NonNull Context context, @NonNull Glide glide, @NonNull Registry registry) { public void registerComponents(@NonNull Context context, @NonNull Glide glide, @NonNull Registry registry) {
//配置glide网络加载框架
ProgressManager.getInstance().setRefreshTime(getRefreshTime()); ProgressManager.getInstance().setRefreshTime(getRefreshTime());
OkHttpClient.Builder builder = ProgressManager.getInstance().withProgress(new OkHttpClient.Builder()); OkHttpClient.Builder builder = ProgressManager.getInstance().withProgress(new OkHttpClient.Builder());
configImageOkHttp(builder);
registry.replace(GlideUrl.class, InputStream.class, new OkHttpUrlLoader.Factory(builder.build())); registry.replace(GlideUrl.class, InputStream.class, new OkHttpUrlLoader.Factory(builder.build()));
} }
//不使用清单配置的方式,减少初始化时间
@Override @Override
public boolean isManifestParsingEnabled() { public boolean isManifestParsingEnabled() {
//不使用清单配置的方式,减少初始化时间
return false; return false;
} }
protected void configImageOkHttp(OkHttpClient.Builder builder) {
}
protected int getRefreshTime() { protected int getRefreshTime() {
return 200; return 200;
} }

@ -18,6 +18,9 @@ public class ActFragWrapper {
private Fragment mFragment; private Fragment mFragment;
private Activity mActivity; private Activity mActivity;
private ActFragWrapper() {
}
public static ActFragWrapper create(Activity activity) { public static ActFragWrapper create(Activity activity) {
ActFragWrapper context = new ActFragWrapper(); ActFragWrapper context = new ActFragWrapper();
context.mActivity = activity; context.mActivity = activity;

@ -109,11 +109,21 @@ public class BannerViewPager extends FrameLayout {
} }
public void setCurrentPosition(int position) { public void setCurrentPosition(int position) {
if (position < 0) {
return;
}
if (mImageUrlList.size() > 1) { if (mImageUrlList.size() > 1) {
if (position <= mImageUrlList.size() - 2) { int realSize = mImageUrlList.size() - 2;
if (position >= realSize) {
position = realSize - 1;
}
if (mOnBannerPositionChangedListener != null) {
mOnBannerPositionChangedListener.onPagePositionChanged(position);
}
position++; position++;
} else { } else {
position = mImageUrlList.size() - 2; if (mOnBannerPositionChangedListener != null) {
mOnBannerPositionChangedListener.onPagePositionChanged(0);
} }
} }
mViewPager.setCurrentItem(position); mViewPager.setCurrentItem(position);

@ -16,7 +16,6 @@ public class CropOptions implements Serializable {
private int outputY; private int outputY;
public CropOptions() { public CropOptions() {
} }
int getAspectX() { int getAspectX() {

Loading…
Cancel
Save