Reputation: 5111
I have a RecyclerView
and each item of RecyclerView
is having ImageView
.
I am loading the image in that ImageView
using Glide, when I scroll down the RecyclerView
it loads images and this is fine, but when I again srcoll up the RecyclerView
it again loads those images which are already been loaded. I do not want to load that images again which have already been loaded.
I am using the below code to load images using Glide
Glide.with(mActivity)
.load(img.getmGridViewImageUrl())
.into(imageHolder.imageView);
Upvotes: 14
Views: 11338
Reputation: 14908
you cannot directly use this method do like below i will work
RequestOptions requestOptions = new RequestOptions();
requestOptions.diskCacheStrategy(DiskCacheStrategy.ALL);
Glide.with( context )
.load( imagesModelList.get(position).getUrl() ).apply(requestOptions)
.into( holder.imageView );
holder.delete_item.setVisibility(View.VISIBLE);
Upvotes: 0
Reputation: 899
after doing this diskCacheStrategy( DiskCacheStrategy.RESULT ) also i am seeing in feedler that this is loading images from network.. i am just scrolling the grid recycler view..
Upvotes: 0
Reputation: 2258
You can cache the images either on disk or in Memory.
By default images are cached in Memory by Glide
If you want to enable cache in disk you can use one of the following
DiskCacheStrategy.SOURCE
caches only the original full-resolution
image.DiskCacheStrategy.RESULT
caches only the final image, after reducing
the resolution (and possibly transformations)DiskCacheStrategy.ALL
caches all versions of the image (default
behavior)Usage :
Glide
.with( context )
.load( url )
.diskCacheStrategy( DiskCacheStrategy.ALL )
.into( imageViewInternet );
Upvotes: 10