Open bingoogolapple opened 6 years ago
非常感谢作者,提到问题立马修改,谢谢。
我按照这样设置Glide3 BGAImage.setImageLoader(new BGAGlideImageLoader3()); 之后,九宫格设置了圆角没有效果了。
兼容最新版Glide 4.9.0如下
/**
* 兼容本项目中最新版Glide 4.9.0
*/
public class BGAGlideImageLoader490 extends BGAImageLoader {
@Override
public void display(ImageView imageView, String path, int loadingResId, int failResId, int width, int height, DisplayDelegate delegate) {
final String finalPath = getPath(path);
Activity activity = getActivity(imageView);
Glide.with(activity).load(finalPath).placeholder(loadingResId).error(failResId).override(width, height).dontAnimate().listener(new RequestListener<Drawable>() {
@Override
public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) {
return false;
}
@Override
public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) {
if (delegate != null) {
delegate.onSuccess(imageView, finalPath);
}
return false;
}
}).into(imageView);
}
@Override
public void download(String path, DownloadDelegate delegate) {
final String finalPath = getPath(path);
Glide.with(BGABaseAdapterUtil.getApp()).asBitmap().load(finalPath).into(new SimpleTarget<Bitmap>() {
@Override
public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition<? super Bitmap> transition) {
if (delegate != null) {
delegate.onSuccess(finalPath, resource);
}
}
@Override
public void onLoadFailed(@Nullable Drawable errorDrawable) {
if (delegate != null) {
delegate.onFailed(finalPath);
}
}
});
}
@Override
public void pause(Activity activity) {
Glide.with(activity).pauseRequests();
}
@Override
public void resume(Activity activity) {
Glide.with(activity).resumeRequestsRecursive();
}
}
兼容最新版Glide 4.9.0如下
/** * 兼容本项目中最新版Glide 4.9.0 */ public class BGAGlideImageLoader490 extends BGAImageLoader { @Override public void display(ImageView imageView, String path, int loadingResId, int failResId, int width, int height, DisplayDelegate delegate) { final String finalPath = getPath(path); Activity activity = getActivity(imageView); Glide.with(activity).load(finalPath).placeholder(loadingResId).error(failResId).override(width, height).dontAnimate().listener(new RequestListener<Drawable>() { @Override public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) { return false; } @Override public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) { if (delegate != null) { delegate.onSuccess(imageView, finalPath); } return false; } }).into(imageView); } @Override public void download(String path, DownloadDelegate delegate) { final String finalPath = getPath(path); Glide.with(BGABaseAdapterUtil.getApp()).asBitmap().load(finalPath).into(new SimpleTarget<Bitmap>() { @Override public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition<? super Bitmap> transition) { if (delegate != null) { delegate.onSuccess(finalPath, resource); } } @Override public void onLoadFailed(@Nullable Drawable errorDrawable) { if (delegate != null) { delegate.onFailed(finalPath); } } }); } @Override public void pause(Activity activity) { Glide.with(activity).pauseRequests(); } @Override public void resume(Activity activity) { Glide.with(activity).resumeRequestsRecursive(); } }
Glide 4.11.0 亲测可用,感谢分享