From e2e8713bc8cc8be284d2c7199675f9952648095f Mon Sep 17 00:00:00 2001 From: gedoor Date: Wed, 12 May 2021 08:26:51 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=A2=84=E4=B8=8B=E8=BD=BDbu?= =?UTF-8?q?g?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/assets/updateLog.md | 3 +++ .../main/java/io/legado/app/service/help/ReadBook.kt | 12 ++++++------ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/app/src/main/assets/updateLog.md b/app/src/main/assets/updateLog.md index 1de59413b..bd696f3fe 100644 --- a/app/src/main/assets/updateLog.md +++ b/app/src/main/assets/updateLog.md @@ -3,6 +3,9 @@ * 关注合作公众号 **[小说拾遗]** 获取好看的小说。 * 旧版数据导入教程:先在旧版阅读(2.x)中进行备份,然后在新版阅读(3.x)【我的】->【备份与恢复】,选择【导入旧版本数据】。 +**2021/05/12** +* 修复预下载bug + **2021/05/11** * 修复部分webDav bug * 修复图片太大时会崩溃的bug diff --git a/app/src/main/java/io/legado/app/service/help/ReadBook.kt b/app/src/main/java/io/legado/app/service/help/ReadBook.kt index 88e7e6fa3..31adc1e33 100644 --- a/app/src/main/java/io/legado/app/service/help/ReadBook.kt +++ b/app/src/main/java/io/legado/app/service/help/ReadBook.kt @@ -21,6 +21,7 @@ import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.delay import kotlinx.coroutines.launch import splitties.init.appCtx +import kotlin.math.max import kotlin.math.min @@ -141,9 +142,9 @@ object ReadBook { GlobalScope.launch(Dispatchers.IO) { val maxChapterIndex = min(chapterSize - 1, durChapterIndex + AppConfig.preDownloadNum) - for (i in 2..maxChapterIndex) { + for (i in durChapterIndex.plus(2)..maxChapterIndex) { delay(1000) - download(durChapterIndex + i) + download(i) } } } @@ -171,11 +172,10 @@ object ReadBook { } loadContent(durChapterIndex.minus(1), upContent, false) GlobalScope.launch(Dispatchers.IO) { - val maxChapterIndex = - min(chapterSize - 1, durChapterIndex + AppConfig.preDownloadNum) - for (i in 2..maxChapterIndex) { + val minChapterIndex = max(0, durChapterIndex - 5) + for (i in durChapterIndex.minus(2) downTo minChapterIndex) { delay(1000) - download(durChapterIndex - i) + download(i) } } }