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) } } }