0

Basically, I am trying to convert a URI -> ImageView (via Picasso) -> Drawable.

var tempimg = ImageView(this)
var a: String
var d: Drawable

    a = pageURIFd + page
    Picasso.get().load(a).into(tempimg)
    d = tempimg.getDrawable() as BitmapDrawable
    bitmaps.add(d)

I know the ImageView is not empty after Picasso loads it because I can display the image. But the line below is returning null. I'm trying to add each drawable to an arraylist.

d = tempimg.getDrawable() as BitmapDrawable
Nikunj
  • 3,937
  • 19
  • 33
Zim
  • 274
  • 4
  • 17

1 Answers1

0

First, Picasso.get().load(a).into(tempimg) is asynchronous. Picasso will do the request in a thread and when it get the result, set it to the ImageView. The next lines of code can't get the result of Picasso.

If you would like to get a Bitmap, you can ask Picasso to return it. See Use Picasso to get a callback with a Bitmap

Kevin Robatel
  • 8,025
  • 3
  • 44
  • 57