Hi,
I creating a MediaBrowser for Android Auto, so i need return a list of MediaItem with the Bitmap representing the Product image. I can do it automatically because Android dont let us modify the MediaItem, so i need get the image synchronously.
There is a method in Picasso to do it? Something like it:
Bitmap b = Picasso.with(this).getFromCache("http://....png.");
if (b != null) {
// aeeee
}
Thanks.
After read the picasso source code i do it:
Bitmap bitmap = Picasso.with(this)
.load(productCoverImageURL)
.error(R.drawable.ic_image_not_available)
.placeholder(R.drawable.ic_image_not_available)
.networkPolicy(NetworkPolicy.OFFLINE)
.get();
But it cannot be executed on MainThead :(
We have no way of querying only the cache synchronously because it uses much more complex keys than the simple URL. If you need an image lookup that can always be queried on the main thread I would recommend maintaining your own cache and only using Picasso to fill/update its entries.
Most helpful comment
After read the picasso source code i do it:
But it cannot be executed on MainThead :(