null drawable from Picasso ImageView

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
    d = tempimg.getDrawable() as BitmapDrawable

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

1 answer

  • answered 2018-04-17 06:08 Kevin Robatel

    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