[英]Glide missing some images in loading
我有一个RecylerView,其中每个项目都包含Iamge,以加载我正在使用Glide的图像。 我面临的问题是列表中未显示某些图像,并且在我的onException回调中,这些图像的Exception和model均为null。
如果您将看到列表中的第四项未显示图像。
这是我编码的方式
Glide.with(context).load(productItem.getImg())
.diskCacheStrategy(DiskCacheStrategy.SOURCE)
.listener(new RequestListener<String, GlideDrawable>() {
@Override
public boolean onException(Exception e, String model, Target<GlideDrawable> target, boolean isFirstResource) {
if( e != null) {
e.printStackTrace();
}
return false;
}
@Override
public boolean onResourceReady(GlideDrawable resource, String model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) {
return false;
}
}).
into(holder.imageViewModel);
enter code here
在xml中我有ImageView这样声明
<ImageView
android:id="@+id/imageViewModel"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_margin="@dimen/cart_vertical_margin"/>
使用以下内容:
Glide.with(mContext).load(productItem.getImg()).asBitmap().centerCrop().into(new SimpleTarget<Bitmap>(200, 200) {
@Override
public void onResourceReady(Bitmap arg0, GlideAnimation<? super Bitmap> arg1) {
// TODO Auto-generated method stub
if (arg0 != null) {
holder.imageViewModel.setImageBitmap(arg0);
} else {
holder.imageViewModel.setImageResource(R.drawable.ic_launcher);
}
}
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.