Fetch images with Callback in Picasso?
I know this is an older question but the fetch()
command allows for callbacks such as fetch(Callback callback)
.
This has an onSuccess()
and onError()
callback for the requested URI load.
See here for javadoc details
Based on the source, it looks like fetch
does nothing upon completion, including notifying any potential listeners. Unfortunately, FetchAction
isn't a public class, so you can't override this functionality either.
You can workaround this problem by using a custom Target
subclass, like this:
Picasso.with(getContext()).load(url).into(new Target() {
@Override public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {
// cache is now warmed up
}
@Override public void onBitmapFailed(Drawable errorDrawable) { }
@Override public void onPrepareLoad(Drawable placeHolderDrawable) { }
});