https://kotlinlang.org logo
l

Luis Daivid

11/19/2020, 6:24 AM
here is my code
Copy code
@Composable
fun ImageItem(image: ImageModel, onClickImage: (ImageModel) -> Unit) {
    Surface(modifier = Modifier.clickable(onClick = { onClickImage(image) })) {
        Column {
            Box(
            ) {
                GlideImage(
                    imageModel = image.imagePath.toUri(),
                    requestOptions = RequestOptions()
                        .override(500, 500)
                        .diskCacheStrategy(DiskCacheStrategy.ALL)
                )
            }
            Text(text = image.name)
        }
    }
}
a

Andrey Kulikov

11/19/2020, 11:34 AM
i think the issue here is that the image is loading asynchronous and for free frames your item has zero size. this confuses the scrolling and dynamic item creations. it would be nice if you can set some fixed size for the items
l

Luis Daivid

11/19/2020, 11:39 AM
@Andrey Kulikov Each image has different width and width, so it cannot be arbitrarily specified. What should I do?
a

Andrey Kulikov

11/19/2020, 11:39 AM
maybe you can at least provide some min height?
l

Luis Daivid

11/19/2020, 11:41 AM
I can apply min, but the problem still occurs.
g

gildor

11/19/2020, 4:44 PM
It doesn't look like a problem unique for compose, Recycler View would have the same problem for such case To mitigate it, GlideImage could cache bitmap to memory (or at least size of it) and set it immediately, if it available, instead of doing async request Also, I would check that memory cache is enabled and images have reasonable size
3 Views