Does anyone know how far `remember{…}` can work on...
# compose
l
Does anyone know how far
remember{…}
can work on a list of Bitmaps? I was trying to use it to remember the state of a Bitmap I loaded from Picasso for list items, but scrolling back and forth on a list, I still see the bitmaps having to reload. Following example here: https://stackoverflow.com/questions/58594262/how-do-i-load-url-into-image-into-drawimage-in-compose-ui-android-jetpack
Copy code
val imageState = remember(id) { loadPicture(url = item.photoUrl) }
private fun loadPicture(url: String?): State<ImageState> {
val imageState: MutableState<ImageState> = mutableStateOf(ImageState.Empty)
... //Picasso
}

sealed class ImageState {
    data class Success(val image: Bitmap) : ImageState()
    object Failed : ImageState()
    object Loading : ImageState()
    object Empty : ImageState()
}
1
d
Remember doesn't remember anything after it gets disposed/ removed from the composition.
You'll probably just need to use a map outside the lazy column.
j
Picasso already implements that map for you though. Re-requesting the same image is effectively free.
l
The weird thing is I still get a delay from Picasso to get the old image. Delay can last up to 30 secs.
When I had this list not in jet pack compose I hardly had a delay at all.