Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Find and load cached Image in Glide

I am new in glide and want to migrate my app from universalimageloader to glide. I want to convert cached image from the disk into image file, and show it into an ImageView.

When I use universalimageloader, I can do it easily with this way:

File imageFile = DiskCacheUtils.findInCache(image_url,  ImageLoader.getInstance().getDiscCache());
//then show it into image view
String file_target = "file://"+imageFile.getPath();
ImageLoader.getInstance().displayImage(target, imageView);

However I have not found a way from documentation to do that in Glide.

Is it possible?

like image 301
ikhsanudinhakim Avatar asked Jun 26 '15 06:06

ikhsanudinhakim


People also ask

Does glide cache images by default?

By default, Glide uses memory and disk caching to avoid unnecessary network calls, it checks into multiple layers of caches before initiating a new request call for an image.

How do you use glide cache?

Glide will put all image resources into the memory cache by default. Thus, a specific call . skipMemoryCache( false ) is not necessary. Hint: beware of the fact, that if you make an initial request to the same URL without the .


1 Answers

Use below code

Glide.with(mContext).load(ImageUrl).diskCacheStrategy(DiskCacheStrategy.SOURCE).into(imageView);
like image 129
Santosh Dhoundiyal Avatar answered Oct 03 '22 12:10

Santosh Dhoundiyal