优化
This commit is contained in:
@@ -73,7 +73,7 @@ object ThemeConfig {
|
|||||||
if (bgCfg.second == 0) {
|
if (bgCfg.second == 0) {
|
||||||
return bgImage
|
return bgImage
|
||||||
}
|
}
|
||||||
return bgImage.stackBlur(bgCfg.second)
|
return bgImage?.stackBlur(bgCfg.second)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun upConfig() {
|
fun upConfig() {
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import io.legado.app.R
|
|||||||
import io.legado.app.constant.AppLog.putDebug
|
import io.legado.app.constant.AppLog.putDebug
|
||||||
import io.legado.app.data.entities.Book
|
import io.legado.app.data.entities.Book
|
||||||
import io.legado.app.data.entities.BookSource
|
import io.legado.app.data.entities.BookSource
|
||||||
|
import io.legado.app.exception.NoStackTraceException
|
||||||
import io.legado.app.help.BookHelp
|
import io.legado.app.help.BookHelp
|
||||||
import io.legado.app.help.coroutine.Coroutine
|
import io.legado.app.help.coroutine.Coroutine
|
||||||
import io.legado.app.model.localBook.EpubFile
|
import io.legado.app.model.localBook.EpubFile
|
||||||
@@ -110,6 +111,7 @@ object ImageProvider {
|
|||||||
@Suppress("BlockingMethodInNonBlockingContext")
|
@Suppress("BlockingMethodInNonBlockingContext")
|
||||||
return try {
|
return try {
|
||||||
val bitmap = BitmapUtils.decodeBitmap(vFile.absolutePath, width, height)
|
val bitmap = BitmapUtils.decodeBitmap(vFile.absolutePath, width, height)
|
||||||
|
?: throw NoStackTraceException("解析图片失败")
|
||||||
bitmapLruCache.put(src, bitmap)
|
bitmapLruCache.put(src, bitmap)
|
||||||
bitmap
|
bitmap
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
|
|||||||
@@ -27,8 +27,7 @@ object BitmapUtils {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Throws(IOException::class)
|
@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)
|
val fis = FileInputStream(path)
|
||||||
return fis.use {
|
return fis.use {
|
||||||
val op = BitmapFactory.Options()
|
val op = BitmapFactory.Options()
|
||||||
@@ -38,7 +37,6 @@ object BitmapUtils {
|
|||||||
op.inSampleSize = calculateInSampleSize(op, width, height)
|
op.inSampleSize = calculateInSampleSize(op, width, height)
|
||||||
op.inJustDecodeBounds = false
|
op.inJustDecodeBounds = false
|
||||||
BitmapFactory.decodeFileDescriptor(fis.fd, null, op)
|
BitmapFactory.decodeFileDescriptor(fis.fd, null, op)
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -71,7 +69,7 @@ object BitmapUtils {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Throws(IOException::class)
|
@Throws(IOException::class)
|
||||||
fun decodeBitmap(path: String): Bitmap {
|
fun decodeBitmap(path: String): Bitmap? {
|
||||||
val fis = FileInputStream(path)
|
val fis = FileInputStream(path)
|
||||||
return fis.use {
|
return fis.use {
|
||||||
val opts = BitmapFactory.Options()
|
val opts = BitmapFactory.Options()
|
||||||
@@ -82,7 +80,6 @@ object BitmapUtils {
|
|||||||
opts.inJustDecodeBounds = false
|
opts.inJustDecodeBounds = false
|
||||||
BitmapFactory.decodeFileDescriptor(fis.fd, null, opts)
|
BitmapFactory.decodeFileDescriptor(fis.fd, null, opts)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user