Workaround loading images from file uri

This commit is contained in:
FooIbar committed 2024-01-03 19:49:47 +08:00
1 parent 876001ad99
commit c30c1b29ef
1 file changed
+5 -1
@@ -109,7 +109,11 @@ class Image private constructor(image: CoilImage, private val src: AutoCloseable
private suspend fun Either<ByteBufferSource, UniFileSource>.decodeCoil(): CoilImage {
val req = appCtx.imageRequest {
onLeft { data(it.source) }
onRight { data(it.source.uri) }
onRight {
// Workaround https://github.com/coil-kt/coil/issues/2006
val uri = it.source.uri
data(if (UniFile.isFileUri(uri)) uri.path else uri)
}
size(targetWidth, targetHeight)
scale(Scale.FILL)
precision(Precision.INEXACT)