|
|
|
@ -16,10 +16,7 @@ import io.legado.app.ui.book.read.page.provider.ChapterProvider |
|
|
|
|
import io.legado.app.ui.book.read.page.provider.ImageProvider |
|
|
|
|
import io.legado.app.utils.msg |
|
|
|
|
import io.legado.app.utils.toastOnUi |
|
|
|
|
import kotlinx.coroutines.Dispatchers |
|
|
|
|
import kotlinx.coroutines.GlobalScope |
|
|
|
|
import kotlinx.coroutines.delay |
|
|
|
|
import kotlinx.coroutines.launch |
|
|
|
|
import splitties.init.appCtx |
|
|
|
|
import kotlin.math.max |
|
|
|
|
import kotlin.math.min |
|
|
|
@ -139,7 +136,7 @@ object ReadBook { |
|
|
|
|
callBack?.upContent() |
|
|
|
|
} |
|
|
|
|
loadContent(durChapterIndex.plus(1), upContent, false) |
|
|
|
|
GlobalScope.launch(Dispatchers.IO) { |
|
|
|
|
Coroutine.async { |
|
|
|
|
val maxChapterIndex = |
|
|
|
|
min(chapterSize - 1, durChapterIndex + AppConfig.preDownloadNum) |
|
|
|
|
for (i in durChapterIndex.plus(2)..maxChapterIndex) { |
|
|
|
@ -157,7 +154,10 @@ object ReadBook { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
fun moveToPrevChapter(upContent: Boolean, toLast: Boolean = true): Boolean { |
|
|
|
|
fun moveToPrevChapter( |
|
|
|
|
upContent: Boolean, |
|
|
|
|
toLast: Boolean = true |
|
|
|
|
): Boolean { |
|
|
|
|
if (durChapterIndex > 0) { |
|
|
|
|
durChapterPos = if (toLast) prevTextChapter?.lastReadLength ?: 0 else 0 |
|
|
|
|
durChapterIndex-- |
|
|
|
@ -171,7 +171,7 @@ object ReadBook { |
|
|
|
|
callBack?.upContent() |
|
|
|
|
} |
|
|
|
|
loadContent(durChapterIndex.minus(1), upContent, false) |
|
|
|
|
GlobalScope.launch(Dispatchers.IO) { |
|
|
|
|
Coroutine.async { |
|
|
|
|
val minChapterIndex = max(0, durChapterIndex - 5) |
|
|
|
|
for (i in durChapterIndex.minus(2) downTo minChapterIndex) { |
|
|
|
|
delay(1000) |
|
|
|
|