I would like to preload images before they are showed to the user. I have a ViewPager where every page is an image. When the activity starts, it calls:
Glide.with(this).load(uri).preload();
After that all the images are preloaded (theoretically), in order to test if the preload works, I disable all network connections and I try to swype between the pages to load the images, but Glide doesn't load them.
In my project, Glide is configured with default values.
Furthermore, if I load the image swyping the viewpager (with internet connection), Glide saves the images in cache.
I tried also using
Glide.with(this).load(uri).downloadOnly(x,y);
with the same results.
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 Glide Cache Works. By default, Glide checks multiple layers of caches before starting a new request for an image: Active resources — Is this image displayed in another View right now? Memory cache — Was this image recently loaded and still in memory?
Deleting cached images Glide does not automatically purge cached images. However, this can be done by your application using the deleteCache() method.
I solved the problem by myself adding the diskCacheStrategy.
Glide.with(this)
.load(uri)
.diskCacheStrategy(DiskCacheStrategy.SOURCE)
.preload();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With