From 5584a22637d8e7d63192b7e8f300ddfe158f8b11 Mon Sep 17 00:00:00 2001 From: AndyBernie Date: Tue, 22 Sep 2020 11:00:31 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8D=A2=E6=BA=90=E6=97=B6=E6=97=A0=E6=9C=80?= =?UTF-8?q?=E6=96=B0=E7=AB=A0=E8=8A=82=E6=97=B6=E8=87=AA=E5=8A=A8=E5=8A=A0?= =?UTF-8?q?=E8=BD=BD=E8=AF=A6=E6=83=85=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../book/changesource/ChangeSourceViewModel.kt | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceViewModel.kt b/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceViewModel.kt index ec423c3dd..581ad9f41 100644 --- a/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceViewModel.kt @@ -120,12 +120,8 @@ class ChangeSourceViewModel(application: Application) : BaseViewModel(applicatio .onSuccess(IO) { it.forEach { searchBook -> if (searchBook.name == name && searchBook.author == author) { - if (context.getPrefBoolean(PreferKey.changeSourceLoadToc)) { - if (searchBook.tocUrl.isEmpty()) { - loadBookInfo(searchBook.toBook()) - } else { - loadChapter(searchBook.toBook()) - } + if (searchBook.latestChapterTitle.isNullOrEmpty()) { + loadBookInfo(searchBook.toBook()) } else { searchFinish(searchBook) } @@ -156,7 +152,14 @@ class ChangeSourceViewModel(application: Application) : BaseViewModel(applicatio App.db.bookSourceDao().getBookSource(book.origin)?.let { bookSource -> WebBook(bookSource).getBookInfo(book, this) .onSuccess { - loadChapter(it) + if (context.getPrefBoolean(PreferKey.changeSourceLoadToc)) { + loadChapter(it) + } else { + //从详情页里获取最新章节 + book.latestChapterTitle = it.latestChapterTitle + val searchBook = book.toSearchBook() + searchFinish(searchBook) + } }.onError { debug { context.getString(R.string.error_get_book_info) } }