In my recyclerview, if I scroll up/down images are reloaded again. it spoils user experience.
I know its default behavior of recyclerview. But I want to implement same like Whatsapp. They do not reload image if already loaded. Anyone suggest to me.
My Glide library code:
BitmapTypeRequest glideRequestmgr = Glide.with(context).load(getGlideURL(path, context)).asBitmap();
glideRequestmgr.diskCacheStrategy(DiskCacheStrategy.ALL)
.dontTransform()
.dontAnimate()
.into(new SimpleTarget<Bitmap>() {
@Override
public void onResourceReady(Bitmap arg0, GlideAnimation<? super Bitmap> arg1) {
imageView.setImageBitmap(arg0);
}
});
Finally I fixed that issue by put the recyclerview inside NestedScrollView
Step 1:
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</android.support.v4.widget.NestedScrollView>
Step 2:
recyclerView.setNestedScrollingEnabled(false);