pull/1787/head
kunfei 3 years ago
parent f78ba7ba1e
commit 312d84b5b6
  1. 9
      app/src/main/java/io/legado/app/ui/book/read/page/provider/ImageProvider.kt

@ -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)
}
} }
} }

Loading…
Cancel
Save