Tiago Nunes
06/01/2021, 2:51 PMlifecycleScope.launch {
val bitmap = withContext(<http://Dispatchers.IO|Dispatchers.IO>) {
getLocalImageAsBitmap(imageName) ?: run {
val file = requireContext().cacheDir.resolve("places").apply { mkdirs() }.resolve(imageName)
try {
repository.downloadFile(imageName, file)
getLocalImageAsBitmap(imageName)
} catch (e: Exception) {
e.printStackTrace()
null
}
} ?: return@withContext null
}
binding.imageView.setImageBitmap(bitmap)
}
How can I migrate this to Compose (LazyColumn)?Adam Powell
06/01/2021, 2:54 PMAdam Powell
06/01/2021, 2:55 PMLaunchedEffect
in the item with imageName
as a key paramTiago Nunes
06/01/2021, 2:56 PMAdam Powell
06/01/2021, 2:56 PMproduceState
as a shortcut to not need to define/remember your own mutableStateOf
to hold the result for your compositionZun
06/02/2021, 9:10 AMTiago Nunes
06/02/2021, 12:20 PM