-1

My question goes thus:

Does Glide create different caches for each object i.e Context, Fragment cause when i used glide to load images into my adapter, on another activity the image is then redownloaded again. And i don't wan't that.

I load the images in the fragment with:

Glide.with(getActivity()).load("<url>").thumbnail(0.1f).crossfade().into(imageView);

And in the opened activity :

Glide.with(this).load("<url>").thumbnail(0.1f).crossfade().into(imageView);

then the image is re-downloaded which consumes more data.

and when i use application context --> the app crashes.

What can i do to fix this behavior?.

pariola
  • 923
  • 12
  • 27

1 Answers1

0

No, Glide doesn't maintain separate caches per Activity or Fragment.

The reason you're getting a cache miss is probably because the View you're using in your Fragment doesn't have exactly the same width and height as the View you're using in your Activity.

You can either use DiskCacheStrategy.SOURCE (only makes sense for remote images), or you can use a fixed size using override() in both places.

Sam Judd
  • 7,317
  • 1
  • 38
  • 38