From fd8ac3ed1d20e9bc996b11311cd599539a13fcf7 Mon Sep 17 00:00:00 2001 From: gedoor Date: Thu, 19 Aug 2021 09:25:01 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/io/legado/app/model/ReadBook.kt | 24 +++++++++++++------ 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/io/legado/app/model/ReadBook.kt b/app/src/main/java/io/legado/app/model/ReadBook.kt index ad51bd6d6..bd7250a70 100644 --- a/app/src/main/java/io/legado/app/model/ReadBook.kt +++ b/app/src/main/java/io/legado/app/model/ReadBook.kt @@ -18,6 +18,7 @@ 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.CoroutineScope +import kotlinx.coroutines.Dispatchers.IO import kotlinx.coroutines.delay import splitties.init.appCtx import kotlin.math.max @@ -150,6 +151,21 @@ object ReadBook { delay(1000) download(i) } + book?.let { book -> + //最后一章时检查更新 + if (durChapterPos == 0 && durChapterIndex == chapterSize - 1) { + webBook?.getChapterList(this, book) + ?.onSuccess(IO) { cList -> + if (book.bookUrl == ReadBook.book?.bookUrl + && cList.size > chapterSize + ) { + appDb.bookChapterDao.insert(*cList.toTypedArray()) + chapterSize = cList.size + nextTextChapter ?: loadContent(1) + } + } + } + } } return true } else { @@ -214,12 +230,6 @@ object ReadBook { readAloud(!BaseReadAloudService.pause) } upReadStartTime() - book?.let { book -> - //最后一章时检查更新 - if (durChapterPos == 0 && durChapterIndex == chapterSize - 1 && book.isOnLineTxt()) { - - } - } } /** @@ -269,7 +279,7 @@ object ReadBook { fun loadContent( index: Int, upContent: Boolean = true, - resetPageOffset: Boolean, + resetPageOffset: Boolean = false, success: (() -> Unit)? = null ) { book?.let { book ->