Glide 4.9使用placeholder()占位图功能,部分图片无法下载更新

解决方法:

1.不使用placeholder()占位图功能.只用error()就可以

2.加上回调监听,然后手动去掉占位图,再更新图片

Glide.with(getContext()).asBitmap().load(dynamicNoticeBean.getAvatar())
        .diskCacheStrategy(DiskCacheStrategy.ALL).placeholder(R.drawable.rc_default_portrait)
        .error(R.drawable.rc_default_portrait).listener(new RequestListener() {
    @Override
    public boolean onLoadFailed(@Nullable GlideException e, Object model, Target target, boolean isFirstResource) {
        Log.e("xxxxxxxxx", "onLoadFailed: ++++++"+position );
        return false;
    }

    @Override
    public boolean onResourceReady(Bitmap resource, Object model, Target target, DataSource dataSource, boolean isFirstResource) {
      //移除展位图
        ((ImageView)holder.getView(R.id.iv_head)).setImageResource(0);
        Log.e("xxxxxxxxx", "onResourceReady: "+position );
        return false;
    }
}).into((ImageView) holder.getView(R.id.iv_head));

你可能感兴趣的:(android)