public void into(Target target) {}
sometime only onPrepareLoad come, onBitmapLoaded not come & onBitmapFailed not come.
if (!data.hasImage()) {
picasso.cancelRequest(target);
target.onPrepareLoad(setPlaceholder ? getPlaceholderDrawable() : null);
return;
here is my source code
Picasso.with(context).load(avatarModel.getUrl())
.placeholder(R.drawable.user_img_default)
.error(R.drawable.user_img_default)
.into(new Target() {
@Override
public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {
Log.i(TAG, "onBitmapLoaded: ");
saveUserAvatar(avatarModel);
if (callBack != null) {
callBack.onBitmapLoaded(bitmap, from);
}
}
@Override
public void onBitmapFailed(Drawable errorDrawable) {
Log.i(TAG, "onBitmapFailed: ");
saveUserAvatar(null);
if (callBack != null) {
callBack.onBitmapFailed(errorDrawable);
}
}
@Override
public void onPrepareLoad(Drawable placeHolderDrawable) {
Log.i(TAG, "onPrepareLoad: ");
if (callBack != null) {
callBack.onPrepareLoad(placeHolderDrawable);
}
}
});
@JakeWharton I have been put forward this problem before。
Do not call into by passing in new Target(). Store the Target instance somewhere that will not be garbage collected (implement on a view, in a view tag, on a view holder) and pass the reference to into.
@hackill what was your solution for this as
@Override
public void onPrepareLoad(Drawable placeHolderDrawable) {
//placeHolderDrawable is returning null
}
Most helpful comment
Do not call
intoby passing innew Target(). Store theTargetinstance somewhere that will not be garbage collected (implement on a view, in a view tag, on a view holder) and pass the reference tointo.