0

I'm making an app that in many other functions, pulls images via URL and then it shows them in a PDF file. I did it on the hard way downloading them and using an asyncTask to handle all the process, but I heard that piccasso does this work better and cleaner so I decided to give it a try. So I want to put the image loaded with piccaso within a Drawable so let's say I'm trying to do something like this:

Drawable drawable=Picasso.get().load("URL");

which of course is ridiculous and it's impossible, so I'm wondering if there is a way I can pull the image with picasso and then transform it to a Drawable so I can then draw it on the PDF file that I need to generate

Zoe
  • 27,060
  • 21
  • 118
  • 148

1 Answers1

1

This code may help you:

Target target = new Target() {
      @Override
      public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {
          imageView.setImageBitmap(bitmap);
          Drawable image = imageView.getDrawable();
      }

    @Override
    public void onBitmapFailed(Drawable errorDrawable) {}

    @Override
    public void onPrepareLoad(Drawable placeHolderDrawable) {}
 };

Picasso.with(this).load("url").into(target);

Or, just look here: https://stackoverflow.com/a/25799983/11162243