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