From 624efcb8f95049d3c11589c25d0a7f82a66c9c9b Mon Sep 17 00:00:00 2001 From: Xwite <1797350009@qq.com> Date: Tue, 12 Apr 2022 21:52:28 +0800 Subject: [PATCH 1/2] =?UTF-8?q?fix:=E6=AD=A3=E6=96=87=E5=9B=BE=E7=89=87?= =?UTF-8?q?=E8=A7=A3=E7=A0=81=E5=A4=A7=E5=B0=8F=E4=B8=8D=E6=AD=A3=E7=A1=AE?= 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, 6 insertions(+), 9 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 f9f7e3b4f..78fd90481 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 @@ -1,10 +1,6 @@ package io.legado.app.ui.book.read.page.provider import android.graphics.Bitmap -import com.bumptech.glide.load.DataSource -import com.bumptech.glide.load.engine.GlideException -import com.bumptech.glide.request.RequestListener -import com.bumptech.glide.request.target.Target import io.legado.app.R import io.legado.app.data.entities.Book import io.legado.app.data.entities.BookSource @@ -52,12 +48,13 @@ object ImageProvider { } } return try { - ImageLoader.loadBitmap(appCtx, vFile.absolutePath).submit().get() + ImageLoader.loadBitmap(appCtx, vFile.absolutePath) + .submit(ChapterProvider.visibleWidth,ChapterProvider.visibleHeight) + .get() } catch (e: Exception) { - Coroutine.async { vFile.delete() } - //must call this method on a background thread - //ImageLoader.loadBitmap(appCtx, R.drawable.image_loading_error).submit().get() - errorBitmap + e.printStackTrace() + Coroutine.async { vFile.delete() } + errorBitmap } } From 7b3a18e52fa24048d2956268f918fabdf279843f Mon Sep 17 00:00:00 2001 From: Xwite <1797350009@qq.com> Date: Wed, 13 Apr 2022 07:31:29 +0800 Subject: [PATCH 2/2] feat:check file type before delete --- .../app/ui/book/read/page/provider/ImageProvider.kt | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 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 78fd90481..2864158d8 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 @@ -2,6 +2,7 @@ package io.legado.app.ui.book.read.page.provider import android.graphics.Bitmap import io.legado.app.R +import io.legado.app.constant.AppLog.putDebug import io.legado.app.data.entities.Book import io.legado.app.data.entities.BookSource import io.legado.app.help.BookHelp @@ -10,6 +11,7 @@ import io.legado.app.help.glide.ImageLoader import io.legado.app.model.localBook.EpubFile import io.legado.app.utils.FileUtils import io.legado.app.utils.BitmapUtils +import io.legado.app.utils.isXml import kotlinx.coroutines.runBlocking import splitties.init.appCtx import java.io.File @@ -52,8 +54,13 @@ object ImageProvider { .submit(ChapterProvider.visibleWidth,ChapterProvider.visibleHeight) .get() } catch (e: Exception) { - e.printStackTrace() - Coroutine.async { vFile.delete() } + Coroutine.async { + putDebug("${vFile.absolutePath} 解码失败", e) + if (FileUtils.readText(vFile.absolutePath).isXml()) { + putDebug("${vFile.absolutePath}为xml,自动删除") + vFile.delete() + } + } errorBitmap } }