From 2decc58aa7748e8eb6729df1c7e8ea776acadb28 Mon Sep 17 00:00:00 2001 From: Horis <821938089@qq.com> Date: Fri, 16 Sep 2022 23:16:10 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/constant/PreferKey.kt | 1 + app/src/main/java/io/legado/app/help/config/AppConfig.kt | 2 ++ .../io/legado/app/ui/book/read/page/ContentTextView.kt | 8 ++++++-- .../app/ui/book/read/page/provider/ImageProvider.kt | 2 +- app/src/main/res/values-es-rES/strings.xml | 1 + app/src/main/res/values-ja-rJP/strings.xml | 1 + app/src/main/res/values-pt-rBR/strings.xml | 1 + app/src/main/res/values-zh-rHK/strings.xml | 1 + app/src/main/res/values-zh-rTW/strings.xml | 1 + app/src/main/res/values-zh/strings.xml | 1 + app/src/main/res/values/strings.xml | 1 + app/src/main/res/xml/pref_config_read.xml | 7 +++++++ 12 files changed, 24 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/io/legado/app/constant/PreferKey.kt b/app/src/main/java/io/legado/app/constant/PreferKey.kt index bc72eabf5..42330282f 100644 --- a/app/src/main/java/io/legado/app/constant/PreferKey.kt +++ b/app/src/main/java/io/legado/app/constant/PreferKey.kt @@ -111,6 +111,7 @@ object PreferKey { const val welcomeShowIconDark = "welcomeShowIconDark" const val pageTouchSlop = "pageTouchSlop" const val showAddToShelfAlert = "showAddToShelfAlert" + const val asyncLoadImage = "asyncLoadImage" const val cPrimary = "colorPrimary" const val cAccent = "colorAccent" diff --git a/app/src/main/java/io/legado/app/help/config/AppConfig.kt b/app/src/main/java/io/legado/app/help/config/AppConfig.kt index 86d93fc46..8b769d020 100644 --- a/app/src/main/java/io/legado/app/help/config/AppConfig.kt +++ b/app/src/main/java/io/legado/app/help/config/AppConfig.kt @@ -320,6 +320,8 @@ object AppConfig : SharedPreferences.OnSharedPreferenceChangeListener { val showAddToShelfAlert get() = appCtx.getPrefBoolean(PreferKey.showAddToShelfAlert, true) + val asyncLoadImage get() = appCtx.getPrefBoolean(PreferKey.asyncLoadImage, false) + val doublePageHorizontal: String? get() = appCtx.getPrefString(PreferKey.doublePageHorizontal) diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/ContentTextView.kt b/app/src/main/java/io/legado/app/ui/book/read/page/ContentTextView.kt index b24d6ce36..39b2cdc62 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/ContentTextView.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/ContentTextView.kt @@ -4,6 +4,7 @@ import android.content.Context import android.graphics.Canvas import android.graphics.Paint import android.graphics.RectF +import android.os.Build import android.util.AttributeSet import android.view.View import io.legado.app.R @@ -51,7 +52,11 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at private var drawVisibleImageOnly = false private var cacheIncreased = false private val increaseSize = 8 * 1024 * 1024 - private val maxCacheSize = 256 * 1024 * 1024 + private val maxCacheSize = if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.N_MR1) { + min(128 * 1024 * 1024, Runtime.getRuntime().maxMemory()) + } else { + 256 * 1024 * 1024 + } //滚动参数 private val pageFactory: TextPageFactory get() = callBack.pageFactory @@ -203,7 +208,6 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at return } if (drawVisibleImageOnly && - isVisible && !cacheIncreased && ImageProvider.isTriggerRecycled() && !ImageProvider.isImageAlive(book, column.src) 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 7a778fc29..8d353a0e5 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 @@ -131,7 +131,7 @@ object ImageProvider { //bitmapLruCache的key同一改成缓存文件的路径 val cacheBitmap = bitmapLruCache.get(vFile.absolutePath) if (cacheBitmap != null) return cacheBitmap - if (height != null && ReadBook.pageAnim() == PageAnim.scrollPageAnim) { + if (height != null && AppConfig.asyncLoadImage && ReadBook.pageAnim() == PageAnim.scrollPageAnim) { Coroutine.async { kotlin.runCatching { val bitmap = BitmapUtils.decodeBitmap(vFile.absolutePath, width, height) diff --git a/app/src/main/res/values-es-rES/strings.xml b/app/src/main/res/values-es-rES/strings.xml index 44af359c8..0739aa62f 100644 --- a/app/src/main/res/values-es-rES/strings.xml +++ b/app/src/main/res/values-es-rES/strings.xml @@ -1028,4 +1028,5 @@ Decode Image(imageDecode) + 异步加载图片 diff --git a/app/src/main/res/values-ja-rJP/strings.xml b/app/src/main/res/values-ja-rJP/strings.xml index ada590af6..98817be18 100644 --- a/app/src/main/res/values-ja-rJP/strings.xml +++ b/app/src/main/res/values-ja-rJP/strings.xml @@ -1031,4 +1031,5 @@ Decode Image(imageDecode) + 异步加载图片 diff --git a/app/src/main/res/values-pt-rBR/strings.xml b/app/src/main/res/values-pt-rBR/strings.xml index 12d27e110..17ebfb35f 100644 --- a/app/src/main/res/values-pt-rBR/strings.xml +++ b/app/src/main/res/values-pt-rBR/strings.xml @@ -1031,4 +1031,5 @@ Decode Image(imageDecode) + 异步加载图片 diff --git a/app/src/main/res/values-zh-rHK/strings.xml b/app/src/main/res/values-zh-rHK/strings.xml index ddd5bef78..432def19b 100644 --- a/app/src/main/res/values-zh-rHK/strings.xml +++ b/app/src/main/res/values-zh-rHK/strings.xml @@ -1028,4 +1028,5 @@ 图片解密(imageDecode) + 异步加载图片 diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml index 0f11cdd39..29aa6bcd6 100644 --- a/app/src/main/res/values-zh-rTW/strings.xml +++ b/app/src/main/res/values-zh-rTW/strings.xml @@ -1030,4 +1030,5 @@ 图片解密(imageDecode) + 异步加载图片 diff --git a/app/src/main/res/values-zh/strings.xml b/app/src/main/res/values-zh/strings.xml index 9df14a606..36df208ef 100644 --- a/app/src/main/res/values-zh/strings.xml +++ b/app/src/main/res/values-zh/strings.xml @@ -1030,4 +1030,5 @@ 图片解密(imageDecode) + 异步加载图片 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 3dba52629..51cbafe59 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1031,4 +1031,5 @@ Decode Image(imageDecode) + 异步加载图片 diff --git a/app/src/main/res/xml/pref_config_read.xml b/app/src/main/res/xml/pref_config_read.xml index 8d4a3cda9..7dd8acfe4 100644 --- a/app/src/main/res/xml/pref_config_read.xml +++ b/app/src/main/res/xml/pref_config_read.xml @@ -120,6 +120,13 @@ app:iconSpaceReserved="false" app:isBottomBackground="true" /> + +