通知数据集更改时,为什么Glide会闪烁ImageView项 [英] Why Glide blink the item ImageView when notifydatasetchanged

查看:527
本文介绍了通知数据集更改时,为什么Glide会闪烁ImageView项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将 Glide 3.7.0 RecyclerView一起使用.刷新(调用notifyDataSetChanged)时,项目视图始终闪烁.

I am using Glide 3.7.0 with RecyclerView. The item view always blinks when refreshing (calling notifyDataSetChanged).

这是我的代码:

Glide
  .with(context)
  .load(filepath)
  .diskCacheStrategy(DiskCacheStrategy.NONE)
  .skipMemoryCache(true)
  .dontAnimate()
  .into(imageview);

当我不使用缓存时,调用notifyDataSetChanged方法并且Glide尚未完成加载位图时,ImageView的位图为空.

When I use no cache, the ImageView has a null Bitmap when notifyDataSetChanged method is called and Glide hasn't finished loading the bitmap.

如果我使用以下代码:

Glide
  .with(context)
  .load(filepath)
  .dontAnimate()
  .into(imageview);

然后ImageView项不再闪烁(使用缓存).

Then the item ImageView does not blink anymore (using cache).

我想动态更新项目视图,因此我禁用了滑行缓存.

I want to update the item view dynamically, so I disable the glide cache.

是否有解决此眨眼错误的解决方案?

Are there any solutions to solve this blink bug?

非常感谢!

推荐答案

经过多次尝试,只需使用SimpleTarget即可解决我的问题 谢谢!

After my many tries, just use SimpleTarget solved my problem thank you!

Glide
.with(context)
.load(filepath)
.asBitmap()
.diskCacheStrategy(DiskCacheStrategy.NONE)
.skipMemoryCache(true)
.dontAnimate()
.into(new SimpleTarget<Bitmap>() {

            @Override
            public void onResourceReady(Bitmap arg0, GlideAnimation<? super Bitmap> arg1) {
                // TODO Auto-generated method stub
                holder.mItemView.setImageBitmap(arg0);
            }
        });

这篇关于通知数据集更改时,为什么Glide会闪烁ImageView项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆