Why does glide blink ImageView when notifydatasetchanged

I am using Glide 3.7.0 with RecyclerView . When updating, the item always blinks (call notifyDataSetChanged ).

Here is my code:

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

When I do not use the cache, ImageView has a zero bitmap when the notifyDataSetChanged method is notifyDataSetChanged , and Glide has not finished loading the bitmap.

If I use the following code:

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

Then the ImageView element no longer blinks (using the cache).

I want to dynamically update the item view, so I will disable the slip skittle.

Are there any solutions to fix this error?

Many thanks!

+8
android blink android-recyclerview android-glide notifydatasetchanged
source share
3 answers

After many of my attempts, just use SimpleTarget to solve my problem thanks!

 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); } }); 
+17
source share

Update Glide from versions 3 to 4 and setSupportsChangeAnimations(false) for a RecyclerView solution for me

 RecyclerView.ItemAnimator animator = recyclerView.getItemAnimator(); if (animator instanceof SimpleItemAnimator) { ((SimpleItemAnimator) animator).setSupportsChangeAnimations(false); } 
0
source share

In my case, I solved the problem using specific dimensions on my imageView .

 <ImageView android:id="@+id/poster_imageview" android:layout_width="130dp" android:layout_height="183dp" android:adjustViewBounds="true" android:scaleType="centerCrop" android:src="@drawable/placeholder" /> 
0
source share

All Articles