I'm switching from Picasso to Glide. Everything works fine except I cannot find a method to get an error callback. I want to retrieve a Bitmap, pass it on and generate an Android Palette from it. Also, while an errorDrawable can be provided to a load call, it won't show up in onResourceReady
when using a SimpleTarget
.
In Picasso I did it like this:
target = new Target() {
@Override
public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {
//handle Bitmap, generate Palette etc.
}
@Override
public void onBitmapFailed(final Drawable errorDrawable) {
// use errorDrawable to generate Palette
}
@Override
public void onPrepareLoad(final Drawable placeHolderDrawable) {
}
};
int width = (int) DisplayUnitsConverter.dpToPx(this, 120);
int height = (int) DisplayUnitsConverter.dpToPx(this, 40);
Picasso.with(this).load(config.getPathToLogo()).resize(width, height).error(errorDrawableId).into(target);
My glide code looks like this:
Glide.with(context)
.load(config.getPathToLogo())
.asBitmap()
.into(new SimpleTarget<Bitmap>(width, height) {
@Override
public void onResourceReady(Bitmap resource, GlideAnimation glideAnimation) {
//handle Bitmap, generate Palette etc.
}
});
Thanks.