This commit is contained in:
kunfei
2022-04-14 23:32:20 +08:00
parent f78ba7ba1e
commit 312d84b5b6

View File

@@ -109,21 +109,20 @@ object ImageProvider {
if (cacheBitmap != null) return cacheBitmap
val vFile = BookHelp.getImage(book, src)
@Suppress("BlockingMethodInNonBlockingContext")
return try {
return kotlin.runCatching {
val bitmap = BitmapUtils.decodeBitmap(vFile.absolutePath, width, height)
?: throw NoStackTraceException("解析图片失败")
bitmapLruCache.put(src, bitmap)
bitmap
} catch (e: Exception) {
}.onFailure {
Coroutine.async {
putDebug("${vFile.absolutePath} 解码失败\n$e", e)
putDebug("${vFile.absolutePath} 解码失败\n$it", it)
if (FileUtils.readText(vFile.absolutePath).isXml()) {
putDebug("${vFile.absolutePath}为xml自动删除")
vFile.delete()
}
}
errorBitmap
}
}.getOrDefault(errorBitmap)
}
}