预下载章节可调整数目

pull/978/head
gedoor 4 years ago
parent ff6f4bf6ee
commit 5b40199891
  1. 25
      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.min
@Suppress("MemberVisibilityCanBePrivate")
@ -137,12 +138,12 @@ object ReadBook {
callBack?.upContent()
}
loadContent(durChapterIndex.plus(1), upContent, false)
if (AppConfig.preDownloadNum) {
GlobalScope.launch(Dispatchers.IO) {
for (i in 2..9) {
delay(1000)
download(durChapterIndex + i)
}
GlobalScope.launch(Dispatchers.IO) {
val maxChapterIndex =
min(chapterSize, durChapterIndex + AppConfig.preDownloadNum)
for (i in 2 until maxChapterIndex) {
delay(1000)
download(durChapterIndex + i)
}
}
}
@ -169,12 +170,12 @@ object ReadBook {
callBack?.upContent()
}
loadContent(durChapterIndex.minus(1), upContent, false)
if (AppConfig.preDownloadNum) {
GlobalScope.launch(Dispatchers.IO) {
for (i in 2..9) {
delay(1000)
download(durChapterIndex - i)
}
GlobalScope.launch(Dispatchers.IO) {
val maxChapterIndex =
min(chapterSize, durChapterIndex + AppConfig.preDownloadNum)
for (i in 2 until maxChapterIndex) {
delay(1000)
download(durChapterIndex - i)
}
}
}

Loading…
Cancel
Save