From f69f4a426a35f600aa33eb3d2dc59058d7eb02e3 Mon Sep 17 00:00:00 2001 From: Xwite <1797350009@qq.com> Date: Fri, 15 Apr 2022 07:35:41 +0800 Subject: [PATCH] fix:return -1 when decode failed --- .../app/ui/book/read/page/provider/ImageProvider.kt | 10 +++++----- 1 file changed, 5 insertions(+), 5 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 e0b1f0184..e11dbdccc 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 @@ -46,8 +46,8 @@ object ImageProvider { ) { if (evicted) { oldBitmap.recycle() - putDebug("自动回收Bitmap path: $key") - putDebug("bitmapLruCache : ${size()} / ${maxSize()}") + putDebug("ImageProvider: trigger bitmap recycle. URI: $key") + putDebug("ImageProvider : cacheUsage ${size()}bytes / ${maxSize()}bytes") } } } @@ -90,7 +90,7 @@ object ImageProvider { // inJustDecodeBounds如果设置为true,仅仅返回图片实际的宽和高,宽和高是赋值给opts.outWidth,opts.outHeight; op.inJustDecodeBounds = true BitmapFactory.decodeFile(file.absolutePath, op) - if (op.outWidth == 0 && op.outHeight == 0) { + if (op.outWidth < 1 && op.outHeight < 1) { return Size(errorBitmap.width, errorBitmap.height) } return Size(op.outWidth, op.outHeight) @@ -116,9 +116,9 @@ object ImageProvider { bitmap }.onFailure { Coroutine.async { - putDebug("${vFile.absolutePath} 解码失败\n$it", it) + putDebug("ImageProvider: decode bitmap failed. path: ${vFile.absolutePath}\n$it", it) if (FileUtils.readText(vFile.absolutePath).isXml()) { - putDebug("${vFile.absolutePath}为xml,自动删除") + putDebug("ImageProvider: delete xml file. path: ${vFile.absolutePath}") vFile.delete() } }