pull/2296/head
kunfei 2 years ago
parent bb82f60e67
commit 4c8c7d8106
  1. 9
      app/src/main/java/io/legado/app/ui/book/read/page/provider/ImageProvider.kt

@ -133,26 +133,21 @@ object ImageProvider {
if (cacheBitmap != null) return cacheBitmap
if (height != null && AppConfig.asyncLoadImage && ReadBook.pageAnim() == PageAnim.scrollPageAnim) {
Coroutine.async {
kotlin.runCatching {
val bitmap = BitmapUtils.decodeBitmap(vFile.absolutePath, width, height)
?: throw NoStackTraceException(appCtx.getString(R.string.error_decode_bitmap))
withContext(Main) {
bitmapLruCache.put(vFile.absolutePath, bitmap)
}
}.onFailure {
}.onError {
//错误图片占位,防止重复获取
withContext(Main) {
bitmapLruCache.put(vFile.absolutePath, errorBitmap)
}
putDebug(
"ImageProvider: decode bitmap failed. path: ${vFile.absolutePath}\n$it",
it
)
}
withContext(Main) {
}.onFinally {
block?.invoke()
}
}
return null
}
@Suppress("BlockingMethodInNonBlockingContext")

Loading…
Cancel
Save