2

In my android application, there is a recyclerview which each item has an image, I've been loaded them with Picasso, the problem is after some scrolling down, if you scroll up some images load again and it's annoying. What can I do to cache all images so no more reloading happens? I know this is not the first time that this question has been asked but after searching a lot I couldn't find a comprehensive solution. Here is how I used Picasso:

Picasso.with(context).load(link).into(myHolder.img);
Siashin
  • 59
  • 8
  • 1
    Possible duplicate of [Android picasso cache images](https://stackoverflow.com/questions/30728511/android-picasso-cache-images) – Luca Nicoletti Nov 26 '17 at 12:49
  • @LucaNicoletti Yes, it's a similar problem but I fetch images in the adapter of recycler view and when items load for the second time images load again. The answer in this link couldn't help. – Siashin Nov 26 '17 at 13:05
  • do you mean it always loaded from network? not from disk/memroy? – hakim Nov 26 '17 at 13:09
  • @hakim not always, most of the time. – Siashin Nov 26 '17 at 13:11
  • 1
    hmm it strange, sorry just to make sure did you enable debug indicator `setIndicatorsEnabled(true)` ? btw, to make image loading looks fast/instantly, you can also disable default fading animation with `noFade()` – hakim Nov 26 '17 at 13:15
  • @hakim no. I wrote all of my Picasso code in question. and thank you for the advice. – Siashin Nov 26 '17 at 13:19

2 Answers2

0

Piccosa loads cached images internally. you don't need to explicitly specify anything.you can read its documentation in order to understand the caching policies. And different types of caching including the default behavior for Picasso caching.

https://futurestud.io/tutorials/picasso-influencing-image-caching

Sami Ikhleaf
  • 156
  • 9
-1
Picasso.with(context).load(link).fit().into(Target) 

will fix your problem

mba3gar
  • 99
  • 1
  • 11
  • This is actually the correct answer. The reason it keeps loading is because of the size of the images. By using `fit()` or `resize(w, h)` will fix this issue - smaller image size = faster caching. – ClassA Sep 19 '18 at 03:48