Skip to content

Instantly share code, notes, and snippets.

@audinue
Created February 7, 2025 05:37
Show Gist options
  • Save audinue/bf2da8dd90e1df07ad709896c83a1823 to your computer and use it in GitHub Desktop.
Save audinue/bf2da8dd90e1df07ad709896c83a1823 to your computer and use it in GitHub Desktop.
setSingletonImageLoaderFactory { context ->
ImageLoader.Builder(context)
.components {
add(object : Fetcher.Factory<Uri> {
override fun create(data: Uri, options: Options, imageLoader: ImageLoader): Fetcher? {
if (data.scheme?.startsWith("jar") == true && data.path?.endsWith(".svg") == true) {
return object : Fetcher {
override suspend fun fetch(): FetchResult? {
return SourceFetchResult(
source = ImageSource(
URI.create(data.toString())
.toURL()
.openStream()
.source()
.buffer(),
options.fileSystem
),
mimeType = "image/svg+xml",
DataSource.DISK
)
}
}
}
return null
}
})
}
.build()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment