I'm trying to use Picasso inside a Java thread (I know it's not necessary to run Picasso in a thread, but my architecture demands it at one point).
Here's my code:
@Override
public void run() {
Log.d(LOG_TAG, "Run " + source);
final Target target = new Target() {
@Override
public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {
Log.d(LOG_TAG, "onBitmapLoaded");
final Bitmap bm = bitmap;
mMainThread.post(new Runnable() {
@Override
public void run() {
callback.onImageDownloaded(bm);
}
});
}
@Override
public void onBitmapFailed(final Drawable errorDrawable) {
Log.d(LOG_TAG, "FAILED");
}
@Override
public void onPrepareLoad(final Drawable placeHolderDrawable) {
Log.d(LOG_TAG, "Prepare Load");
}
};
Picasso.with(context).load(source).resize(width, height).into(target);
}
The run function is executed using Android's ThreadPoolExecutor
. The function is called, but none of the callbacks (onBitmapLoaded
, onBitmapFailed
, onPrepareLoad
) are ever called.
What am i doing wrong?