Image loading with the Picasso implementation on android

Asked

Viewed 144 times

-2

I am using the Picasso implementation to upload the images in my application. However, I am using the reverie effect of the shimmerfacebook implementation to make the layout more user-friendly. For those who do not know, this implementation is a brightness effect that indicates that the image is being loaded. My intention is to detect in Icasso when the image was loaded so that I can remove the effect, since this is only removed dynamically.

Picasso.get().load(https://imagem....).into.(imageView);

Detect that image has been loaded.

1 answer

0

At the last quarter. into() you can pass a Callback type object as the second parameter and use onSuccess() and/or onerror() to know when the Picasso loading has ended.

Example of into with callback using Kotlin:

 val requestOptions = Picasso.with(imageView.context).load(imagePath)
 requestOptions.into(this, object :Callback{
        override fun onSuccess() {
            TODO("FAZER ALGO")
        }

        override fun onError() {
            TODO("FAZER ALGO")
        }
    })

Javadoc: https://square.github.io/picasso/2.x/picasso/com/squareup/picasso/RequestCreator.html#into-android.widget.Imageview-com.squareup.Picasso.Callback-

Browser other questions tagged

You are not signed in. Login or sign up in order to post.