I'm using Picasso to download images for my app.
I'm in a situation where I need to access the Bitmap
first before it's loaded into the ImageView
. The presence of the Downloader.Response
class seems to suggest this is possible, but I can't find any use examples. I don't want to write a bunch more code to asynchronously handle this one particular case if it's possible to do with Picasso.
Can anyone show me how to do it?
What can be easy than next:
Should be called from not the main thread!
or with RxJava 2:
Retrieve Bitmap:
I used Picasso v.2.5.2
with using target garbage collector run out your plans.so I do a trick with this sample code:
now you can enjoy your bitmap; :))
taken from here:
Updated (May 04, 2016):
Updated (November 22, 2016)
or using a strong reference for
Target
so that it wont be garbage collectedKotlin
I thought maybe some of you would like an RxJava version of the above answer... Here it is:
P.S. When subscribing, store the subscription reference on your activity, otherwise, target will be GC'd before you receive a response...
Found the answer on github in case anyone is wondering:
The post recommends not using an anonymous callback, and instead using an instance variable for target.