0
Glide RequestListener
無法正常工作(我正在使用它在recycler view
下載後保存圖像)。這是相關的代碼。Glide RequestListener不工作
public class GlideImageView extends ImageView {
public void setImageURI(String uri) {
setImageUri(uri);
}
private <T> void setImageUri(T uri) {
Context context = getContext();
if (uri != null) {
DrawableTypeRequest<T> request = Glide.with(context)
.load(uri);
request.asBitmap()
.diskCacheStrategy(DiskCacheStrategy.ALL)
.listener(new RequestListener<T, Bitmap>() {
@Override
public boolean onException(Exception e, T model, Target<Bitmap> target, boolean isFirstResource) {
Log.e("Exception !!!" , e.getMessage());
return false;
}
@Override
public boolean onResourceReady(Bitmap resource, T model, Target<Bitmap> target, boolean isFromMemoryCache, boolean isFirstResource) {
Log.e("I am working" , "regards request listener");
return false;
}
});
if (placeHolderDrawable != null) {
request.placeholder(placeHolderDrawable);
}
request.into(this);
} else {
Glide.clear(this);
setImageDrawable(placeHolderDrawable);
}
}
}
我發現在GenericRequest類requestListener
是在方法onResourceReady(Resource<?> resource, R result)
空。
監聽器根本沒有被調用。