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 df88392a1..f485ab7be 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 @@ -10,8 +10,8 @@ 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.help.config.AppConfig +import io.legado.app.help.coroutine.Coroutine import io.legado.app.model.localBook.EpubFile import io.legado.app.utils.BitmapUtils import io.legado.app.utils.FileUtils @@ -20,8 +20,6 @@ import kotlinx.coroutines.withContext import splitties.init.appCtx import java.io.File import java.io.FileOutputStream -import kotlin.math.max -import kotlin.math.min object ImageProvider { @@ -33,7 +31,7 @@ object ImageProvider { *缓存bitmap LruCache实现 */ private const val M = 1024 * 1024 - private val cacheSize = AppConfig.bitmapCacheSize * M + val cacheSize get() = AppConfig.bitmapCacheSize * M val bitmapLruCache = object : LruCache(cacheSize) { override fun sizeOf(key: String, bitmap: Bitmap): Int { diff --git a/app/src/main/java/io/legado/app/ui/config/OtherConfigFragment.kt b/app/src/main/java/io/legado/app/ui/config/OtherConfigFragment.kt index 03ea90822..9f9f9e038 100644 --- a/app/src/main/java/io/legado/app/ui/config/OtherConfigFragment.kt +++ b/app/src/main/java/io/legado/app/ui/config/OtherConfigFragment.kt @@ -21,6 +21,7 @@ import io.legado.app.lib.theme.primaryColor import io.legado.app.model.CheckSource import io.legado.app.receiver.SharedReceiverActivity import io.legado.app.service.WebService +import io.legado.app.ui.book.read.page.provider.ImageProvider import io.legado.app.ui.document.HandleFileContract import io.legado.app.ui.widget.number.NumberPickerDialog import io.legado.app.utils.* @@ -106,7 +107,6 @@ class OtherConfigFragment : PreferenceFragment(), PreferKey.uploadRule -> showDialogFragment() PreferKey.checkSource -> showDialogFragment() PreferKey.bitmapCacheSize -> { - toastOnUi(R.string.restart_to_apply_changes) NumberPickerDialog(requireContext()) .setTitle(getString(R.string.bitmap_cache_size)) .setMaxValue(9999) @@ -114,6 +114,7 @@ class OtherConfigFragment : PreferenceFragment(), .setValue(AppConfig.bitmapCacheSize) .show { AppConfig.bitmapCacheSize = it + ImageProvider.bitmapLruCache.resize(ImageProvider.cacheSize) } } }