compose-imageloader
compose-imageloader copied to clipboard
Support for bitmap or drawable in Android target
Would it be possible to provide a Bitmap or Drawable in addition to Painter when the image is successfully downloaded in Android target similar to Coil-Compose? Coil:
DisposableEffect(url) {
val request = ImageRequest.Builder(context)
.data(data = url)
.target { drawable ->
val bitmap = drawable.toBitmapOrNull() ?: return@target
// TODO use bitmap
}
.build()
val disposable = ImageLoader.Builder(context)
.components { add(SvgDecoder.Factory()) }
.build()
.enqueue(request)
onDispose {
disposable.dispose()
}
}
you can do this:
val imageLoader = LocalImageLoader.current
LaunchedEffect(Unit) {
val request = ImageRequest("data")
val result = imageLoader.execute(request)
if (result is ImageResult.Bitmap) {
result.bitmap
} else if (result is ImageResult.Image) {
result.image.drawable
} else if (result is ImageResult.Painter) {
result.painter // svg return painter
}
}
I think this is more simple way of looking at it and don't want to add target
for now.
but svg return a painter, not bitmap.