修复预下载bug

This commit is contained in:
gedoor 2021-05-12 08:26:51 +08:00
parent 187942099f
commit e2e8713bc8
2 changed files with 9 additions and 6 deletions

View File

@ -3,6 +3,9 @@
* 关注合作公众号 **[小说拾遗]** 获取好看的小说。
* 旧版数据导入教程:先在旧版阅读(2.x)中进行备份,然后在新版阅读(3.x)【我的】->【备份与恢复】,选择【导入旧版本数据】。
**2021/05/12**
* 修复预下载bug
**2021/05/11**
* 修复部分webDav bug
* 修复图片太大时会崩溃的bug

View File

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