I have a fairly large list of image URL's that I'm using to load up a ViewPager
using Picasso. I need to be able to provide sharing capabilities for these images via an intent (ultimately sharing via ShareActionProvider). From what I've read, Picasso isn't really built to handle this sort of thing out of the box, though it provides all the necessary tools to do so.
My plan before research was to create a simple LruCache
which uses the url as the key and bitmap value. This caching would occur in onBitmapLoaded
via Picasso's Target
interface. Whenever I want to share an image, I'll check the cache for the bitmap. If it's not there, I'll fetch with Picasso. Now that I have a cached bitmap regardless, I'll write to a file (...this part doesn't seem right, though I have to write to a file to get a uri, right?) and add the file uri to the intent.
However I see that with the Picasso.Builder
I can set (and retain a reference to) my own cache - https://mcmap.net/q/750202/-how-to-retrieve-images-from-cache-memory-in-picasso. This means I could do away with the custom Target
and confusion with properly implementing hashCode
and equals
methods to ensure accurate recycling, retrieval, etc.
My question is, how does Picasso use this cache? What are the keys? Is there a way to get a bitmap Uri without writing it to disk?