android: Fix list updating for image and QR code

This commit is contained in:
Harry Cheng 2022-06-11 13:11:33 +08:00
parent c6caf87a0a
commit 4673418d95
2 changed files with 21 additions and 15 deletions

View File

@ -136,15 +136,16 @@ fun KeyItem(key: PushKey, requestHolder: RequestHolder) {
) {
AndroidView(
factory = {
ImageView(it).apply {
this.setImageBitmap(
QRCodeGenerator(
key.key,
400.dp.value.toInt(),
400.dp.value.toInt()
).qrCode
)
}
ImageView(it)
},
update = { view ->
view.setImageBitmap(
QRCodeGenerator(
key.key,
400.dp.value.toInt(),
400.dp.value.toInt()
).qrCode
)
},
modifier = Modifier.align(alignment = Alignment.Center)
)

View File

@ -137,12 +137,17 @@ fun ImageMessageItem(message: MessageEntity, requestHolder: RequestHolder) {
)
}
Card(modifier = Modifier.fillMaxWidth()) {
AndroidView(factory = {
ImageView(it).apply {
scaleType = ImageView.ScaleType.FIT_CENTER
load(message.text, requestHolder.coilImageLoader)
}
}, modifier = Modifier.fillMaxWidth())
AndroidView(
factory = {
ImageView(it).apply {
scaleType = ImageView.ScaleType.FIT_CENTER
}
},
update = { view ->
view.load(message.text, requestHolder.coilImageLoader)
},
modifier = Modifier.fillMaxWidth()
)
}
}
}