pull/1787/head
kunfei 3 years ago
parent 0c27af83bd
commit f78ba7ba1e
  1. 2
      app/src/main/java/io/legado/app/help/config/ThemeConfig.kt
  2. 2
      app/src/main/java/io/legado/app/ui/book/read/page/provider/ImageProvider.kt
  3. 7
      app/src/main/java/io/legado/app/utils/BitmapUtils.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() {

@ -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) {

@ -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)
}
}
/**

Loading…
Cancel
Save