代码如下:
Glide.with(mContext)
.load(imgUrl)
.into(new DrawableImageViewTarget(iv) {
@Override
public void onLoadStarted(@Nullable Drawable placeholder) {
LogUtils.e(TAG, "onLoadStarted");
super.onLoadStarted(placeholder);
view.setBackground(mContext.getResources().getDrawable(R.drawable.common_img_imageloder_default));
}
@Override
public void onLoadFailed(@Nullable Drawable errorDrawable) {
LogUtils.e(TAG, "onLoadFailed");
super.onLoadFailed(errorDrawable);
view.setBackground(mContext.getResources().getDrawable(R.drawable.common_img_imageloder_default));
}
@Override
public void onResourceReady(@NonNull Drawable resource, @Nullable Transition<? super Drawable> transition) {
LogUtils.e(TAG, "onResourceReady");
view.setBackground(resource);
}
@Override
public void onLoadCleared(@Nullable Drawable placeholder) {
LogUtils.e(TAG, "onLoadCleared");
super.onLoadCleared(placeholder);
view.setBackground(null);
}
});
网友评论