In Compose AsyncImage, how do I set custom ImageRequest.Listener? #1566
Unanswered
aldo-astro
asked this question in
Q&A
Replies: 2 comments
-
Is it the correct way to listen to state in AsyncImage? AsyncImage(
onState = {
when (it) {
is AsyncImagePainter.State.Empty -> {}
is AsyncImagePainter.State.Error-> {}
is AsyncImagePainter.State.Loading-> {}
is AsyncImagePainter.State.Success-> {}
}
}, |
Beta Was this translation helpful? Give feedback.
0 replies
-
Another approach.. val imageLoader = ImageLoader.Builder(androidContext())
.okHttpClient(okHttpClient)
.eventListener(object : EventListener {
override fun onStart(request: ImageRequest) {
}
override fun onSuccess(request: ImageRequest, result: SuccessResult) {
}
override fun onError(request: ImageRequest, result: ErrorResult) {
}
})
.build()
Coil.setImageLoader(imageLoader) |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
In
ImageView.load
function (not Compose), we can attach customImageRequest.Listener
to receive the image request is successful or not. For example:But I don't see the same functionality in
AsyncImage
.So, how do I set custom
ImageRequest.Listener
in Coil Compose? Did I miss something?Thank you in advance 🙏
Beta Was this translation helpful? Give feedback.
All reactions