From 9540016c917630265d2dc77a23379f267d695cb0 Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 15 Apr 2022 08:09:32 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ui/book/read/page/provider/ImageProvider.kt | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 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 e11dbdccc..e000fa311 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 @@ -44,11 +44,9 @@ object ImageProvider { oldBitmap: Bitmap, newBitmap: Bitmap? ) { - if (evicted) { - oldBitmap.recycle() - putDebug("ImageProvider: trigger bitmap recycle. URI: $key") - putDebug("ImageProvider : cacheUsage ${size()}bytes / ${maxSize()}bytes") - } + oldBitmap.recycle() + putDebug("ImageProvider: trigger bitmap recycle. URI: $key") + putDebug("ImageProvider : cacheUsage ${size()}bytes / ${maxSize()}bytes") } } @@ -90,7 +88,7 @@ object ImageProvider { // inJustDecodeBounds如果设置为true,仅仅返回图片实际的宽和高,宽和高是赋值给opts.outWidth,opts.outHeight; op.inJustDecodeBounds = true BitmapFactory.decodeFile(file.absolutePath, op) - if (op.outWidth < 1 && op.outHeight < 1) { + if (op.outWidth <= 0 && op.outHeight <= 0) { return Size(errorBitmap.width, errorBitmap.height) } return Size(op.outWidth, op.outHeight) @@ -116,7 +114,10 @@ object ImageProvider { bitmap }.onFailure { Coroutine.async { - putDebug("ImageProvider: decode bitmap failed. path: ${vFile.absolutePath}\n$it", it) + putDebug( + "ImageProvider: decode bitmap failed. path: ${vFile.absolutePath}\n$it", + it + ) if (FileUtils.readText(vFile.absolutePath).isXml()) { putDebug("ImageProvider: delete xml file. path: ${vFile.absolutePath}") vFile.delete()