From dd400833564571d4ca2f54c7180389f79e1e8776 Mon Sep 17 00:00:00 2001 From: Xwite <1797350009@qq.com> Date: Thu, 14 Apr 2022 19:29:54 +0800 Subject: [PATCH] refactor(ImageProvider.kt):minify code --- .../book/read/page/provider/ImageProvider.kt | 30 +------------------ 1 file changed, 1 insertion(+), 29 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/provider/ImageProvider.kt b/app/src/main/java/io/legado/app/ui/book/read/page/provider/ImageProvider.kt index af6cbed8d..4cc9ad64c 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/provider/ImageProvider.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/provider/ImageProvider.kt @@ -96,7 +96,7 @@ object ImageProvider { book: Book, src: String, width: Int, - height: Int + height: Int? = null ): Bitmap { val cacheBitmap = bitmapLruCache.get(src) if (cacheBitmap != null) return cacheBitmap @@ -118,32 +118,4 @@ object ImageProvider { } } - /** - *获取bitmap 使用LruCache缓存 - */ - fun getImage( - book: Book, - src: String, - width: Int - ): Bitmap { - val cacheBitmap = bitmapLruCache.get(src) - if (cacheBitmap != null) return cacheBitmap - val vFile = BookHelp.getImage(book, src) - @Suppress("BlockingMethodInNonBlockingContext") - return try { - val bitmap = BitmapUtils.decodeBitmap(vFile.absolutePath, width) - bitmapLruCache.put(src, bitmap) - bitmap - } catch (e: Exception) { - Coroutine.async { - putDebug("${vFile.absolutePath} 解码失败\n$e", e) - if (FileUtils.readText(vFile.absolutePath).isXml()) { - putDebug("${vFile.absolutePath}为xml,自动删除") - vFile.delete() - } - } - errorBitmap - } - } - }