0

I have a large list of links to images (List<Strings>). Is there an easy way to download the first available image? I do not want to manually catch the error and run the new loading instance (or I just do not understand how to do it simply).

I just thought that Picasso has the download/attempts queue or something like that. But I did not find anything in the documentation.

Mikhail
  • 2,612
  • 3
  • 22
  • 37

1 Answers1

1

What have you tried? Can you simply do something like the following? (just off the top of my head to give the idea, not cleaned up.)

List<String> urls;
if (!urls.isEmpty()) {
  picasso.load(urls.get(0)).into(target, new Callback.EmptyCallback() {
    @Override
    public void onSuccess() {
      urls.remove(0);
      if (!urls.isEmpty()) {
        picasso.load(urls.get(0)).into(target, this);
      }
    }
  });
}
Eric Cochran
  • 8,414
  • 5
  • 50
  • 91