Picasso: Allow for fallback url on error

Created on 1 Dec 2015  路  1Comment  路  Source: square/picasso

Allow us to set a fallback url to call in case the first request is unsuccessful.

My usecase is a list with thumbnails. The problem is the Wordpress server doesn't create one for every image, but I cannot know that beforehand. I would use Picasso.with(context).load(thumbUrl).fallback(originalUrl).into(image) .

I can't think of a solution that doesn't involve a Target (losing animations and maybe some optimizations).

Most helpful comment

You should be able to do this yourself.

Picasso.with(context).load(url).into(imageView, new Callback() {
  @Override public void onSuccess() {}
  @Override public void onError() {
    Picasso.with(context).load(errorUrl).into(imageView);
  }
}

>All comments

You should be able to do this yourself.

Picasso.with(context).load(url).into(imageView, new Callback() {
  @Override public void onSuccess() {}
  @Override public void onError() {
    Picasso.with(context).load(errorUrl).into(imageView);
  }
}
Was this page helpful?
0 / 5 - 0 ratings