9

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.

Sam Judd
  • 7,317
  • 1
  • 38
  • 38
fran
  • 1,119
  • 1
  • 10
  • 27

1 Answers1

12

I solved the problem by myself adding the diskCacheStrategy.

Glide.with(this)
     .load(uri)
     .diskCacheStrategy(DiskCacheStrategy.SOURCE)
     .preload();
fran
  • 1,119
  • 1
  • 10
  • 27