diff --git a/app/src/main/java/io/legado/app/help/config/ThemeConfig.kt b/app/src/main/java/io/legado/app/help/config/ThemeConfig.kt index 612a4ec3a..84be2aaa4 100644 --- a/app/src/main/java/io/legado/app/help/config/ThemeConfig.kt +++ b/app/src/main/java/io/legado/app/help/config/ThemeConfig.kt @@ -73,7 +73,7 @@ object ThemeConfig { if (bgCfg.second == 0) { return bgImage } - return bgImage.stackBlur(bgCfg.second) + return bgImage?.stackBlur(bgCfg.second) } fun upConfig() { 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 0bd39871c..cd05bed6e 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 @@ -8,6 +8,7 @@ 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.exception.NoStackTraceException import io.legado.app.help.BookHelp import io.legado.app.help.coroutine.Coroutine import io.legado.app.model.localBook.EpubFile @@ -110,6 +111,7 @@ object ImageProvider { @Suppress("BlockingMethodInNonBlockingContext") return try { val bitmap = BitmapUtils.decodeBitmap(vFile.absolutePath, width, height) + ?: throw NoStackTraceException("解析图片失败") bitmapLruCache.put(src, bitmap) bitmap } catch (e: Exception) { diff --git a/app/src/main/java/io/legado/app/utils/BitmapUtils.kt b/app/src/main/java/io/legado/app/utils/BitmapUtils.kt index 797de8008..c237deba7 100644 --- a/app/src/main/java/io/legado/app/utils/BitmapUtils.kt +++ b/app/src/main/java/io/legado/app/utils/BitmapUtils.kt @@ -27,8 +27,7 @@ object BitmapUtils { * @return */ @Throws(IOException::class) - fun decodeBitmap(path: String, width: Int, height: Int? = null): Bitmap { - + fun decodeBitmap(path: String, width: Int, height: Int? = null): Bitmap? { val fis = FileInputStream(path) return fis.use { val op = BitmapFactory.Options() @@ -38,7 +37,6 @@ object BitmapUtils { op.inSampleSize = calculateInSampleSize(op, width, height) op.inJustDecodeBounds = false BitmapFactory.decodeFileDescriptor(fis.fd, null, op) - } } @@ -71,7 +69,7 @@ object BitmapUtils { * @return */ @Throws(IOException::class) - fun decodeBitmap(path: String): Bitmap { + fun decodeBitmap(path: String): Bitmap? { val fis = FileInputStream(path) return fis.use { val opts = BitmapFactory.Options() @@ -82,7 +80,6 @@ object BitmapUtils { opts.inJustDecodeBounds = false BitmapFactory.decodeFileDescriptor(fis.fd, null, opts) } - } /**