From e1711cae2761e8bbd138e3dca89ca86ca7afc792 Mon Sep 17 00:00:00 2001 From: gedoor Date: Wed, 19 Aug 2020 15:49:54 +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 --- .../io/legado/app/service/help/ReadBook.kt | 18 +++++++++++------- .../app/ui/book/read/ReadBookActivity.kt | 6 +++++- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/io/legado/app/service/help/ReadBook.kt b/app/src/main/java/io/legado/app/service/help/ReadBook.kt index 7878cb1c2..afb7702a8 100644 --- a/app/src/main/java/io/legado/app/service/help/ReadBook.kt +++ b/app/src/main/java/io/legado/app/service/help/ReadBook.kt @@ -7,6 +7,7 @@ import io.legado.app.R import io.legado.app.constant.BookType import io.legado.app.data.entities.Book import io.legado.app.data.entities.BookChapter +import io.legado.app.data.entities.BookSource import io.legado.app.help.AppConfig import io.legado.app.help.BookHelp import io.legado.app.help.IntentDataHelp @@ -35,6 +36,7 @@ object ReadBook { var prevTextChapter: TextChapter? = null var curTextChapter: TextChapter? = null var nextTextChapter: TextChapter? = null + var bookSource: BookSource? = null var webBook: WebBook? = null var msg: String? = null private val loadingChapters = arrayListOf() @@ -54,14 +56,16 @@ object ReadBook { } fun upWebBook(book: Book) { - webBook = if (book.origin == BookType.local) { - null + if (book.origin == BookType.local) { + bookSource = null + webBook = null } else { - val bookSource = App.db.bookSourceDao().getBookSource(book.origin) - if (bookSource != null) { - WebBook(bookSource) - } else { - null + App.db.bookSourceDao().getBookSource(book.origin)?.let { + bookSource = it + webBook = WebBook(it) + } ?: let { + bookSource = null + webBook = null } } } diff --git a/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt b/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt index 512d22a6f..42f4a45df 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt @@ -632,7 +632,11 @@ class ReadBookActivity : VMBaseActivity(R.layout.activity_boo * 替换 */ override fun openReplaceRule() { - startActivityForResult(requestCodeReplace) + startActivityForResult( + requestCodeReplace, + Pair("bookName", ReadBook.book?.name), + Pair("bookSource", ReadBook.bookSource?.bookSourceUrl) + ) } /**