I have some images that I download from different web sites when the app starts, by doing this:
Picasso.with(context).load(image_url).fetch();
Now, suppose the user closes the app and turns offline. When the app starts again, Picasso display the images in this way:
Picasso.with(ctx).load(image_url).placeholder(R.drawable.ph).into(imageView);
The problem is that some images are loaded from the disk cache (yellow triangle in debug mode), and for the others Picasso shows the placeholder.
Why? I'm expecting that every image is loaded from the disk cache.
To avoid creating of separate instance of
RequestCreator
like here , do this:You can use this code by this strategy Picasso will look for images in cache and if it failed only then image will be downloaded over network.
Do this:
Also check my previous answer, maybe will help you: Invalidate cache in Picasso
This logic worked for me:
Is OkHttp and Okio present on the class path? (or in your dependencies) Because by default Picasso lets the HttpClient handle the caching (it does not do this by default)
You have 2 options