我需要重新加载/刷新线圈图像,因为它已被重写到磁盘/存储我正在使用的代码
val context = LocalContext.current
val loader = if (!isSvg) {
LocalImageLoader.current ?: remember { ImageLoader(context) }
} else {
remember {
ImageLoader.Builder(context)
.componentRegistry {
add(SvgDecoder(context))
}.build()
}
}
val painter = rememberCoilPainter(request = request, imageLoader = loader)
LaunchedEffect(key1 = invalidate, block = {
val result = loader.execute(
ImageRequest.Builder(context)
.diskCachePolicy(if (fromCache) CachePolicy.ENABLED else CachePolicy.DISABLED)
.data(request).build()
)
Log.d("TL_ImageLoadRes", result.toString())
})
Box(modifier = Modifier.background(MaterialTheme.colors.onBackground.copy(.4f))) {
Image(
modifier = modifier,
painter = painter,
contentDescription = stringResource(R.string.random_image),
contentScale = contentScale
)
}
每次无效更改,这意味着图像已被重写,现在可以找到并且我执行 LaunchedEffect 但在获得成功结果后我不知道将它放在哪里,它包含一个 Drawable ,我不知道该做什么用它做