Why Glide blink the item ImageView when notifydatasetchanged
Update Glide from version 3 to 4 and setSupportsChangeAnimations(false)
for RecyclerView solved problem for me
RecyclerView.ItemAnimator animator = recyclerView.getItemAnimator();
if (animator instanceof SimpleItemAnimator) {
((SimpleItemAnimator) animator).setSupportsChangeAnimations(false);
}
since SimpleTarget
is deprecated try this solution:
GlideApp.with(SOMETHING)
.load("WHAT")
.dontAnimate()
.let { request ->
if(imageView.drawable != null) {
request.placeholder(imageView.drawable.constantState?.newDrawable()?.mutate())
} else {
request
}
}
.into(imageView)
you can also create nice extension for drawable to make REAL copy:
import android.graphics.drawable.Drawable
fun Drawable.copy() = constantState?.newDrawable()?.mutate()
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);
}
});