From 3ba16a772749571bf6bfc956099844b949063817 Mon Sep 17 00:00:00 2001 From: gedoor Date: Sat, 24 Oct 2020 22:23:07 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E9=87=8D=E6=96=B0=E5=88=86?= =?UTF-8?q?=E6=AE=B5=E5=8A=9F=E8=83=BD,=E9=92=88=E5=AF=B9=E6=AF=8F?= =?UTF-8?q?=E6=9C=AC=E4=B9=A6,=E5=9C=A8=E8=8F=9C=E5=8D=95=E9=87=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/io/legado/app/help/BookHelp.kt | 21 ++++++++++--------- .../io/legado/app/service/help/ReadBook.kt | 8 +------ .../searchContent/SearchContentActivity.kt | 8 +------ 3 files changed, 13 insertions(+), 24 deletions(-) diff --git a/app/src/main/java/io/legado/app/help/BookHelp.kt b/app/src/main/java/io/legado/app/help/BookHelp.kt index 18222d870..d99977101 100644 --- a/app/src/main/java/io/legado/app/help/BookHelp.kt +++ b/app/src/main/java/io/legado/app/help/BookHelp.kt @@ -318,23 +318,24 @@ object BookHelp { } suspend fun disposeContent( + book: Book, title: String, - name: String, - origin: String?, content: String, - enableReplace: Boolean, ): List { var title1 = title var content1 = content - if (enableReplace) { + if (book.getReSegment()) { + content1 = ContentHelp.reSegment(content1, title1) + } + if (book.getUseReplaceRule()) { synchronized(this) { - if (bookName != name || bookOrigin != origin) { - bookName = name - bookOrigin = origin - replaceRules = if (origin.isNullOrEmpty()) { - App.db.replaceRuleDao().findEnabledByScope(name) + if (bookName != book.name || bookOrigin != book.origin) { + bookName = book.name + bookOrigin = book.origin + replaceRules = if (bookOrigin.isNullOrEmpty()) { + App.db.replaceRuleDao().findEnabledByScope(bookName!!) } else { - App.db.replaceRuleDao().findEnabledByScope(name, origin) + App.db.replaceRuleDao().findEnabledByScope(bookName!!, bookOrigin!!) } } } 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 54e772a46..3ed6c7809 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 @@ -378,13 +378,7 @@ object ReadBook { 2 -> HanLP.convertToTraditionalChinese(chapter.title) else -> chapter.title } - val contents = BookHelp.disposeContent( - chapter.title, - book.name, - webBook?.bookSource?.bookSourceUrl, - content, - book.getUseReplaceRule() - ) + val contents = BookHelp.disposeContent(book, chapter.title, content) when (chapter.index) { durChapterIndex -> { curTextChapter = diff --git a/app/src/main/java/io/legado/app/ui/book/searchContent/SearchContentActivity.kt b/app/src/main/java/io/legado/app/ui/book/searchContent/SearchContentActivity.kt index 270c99f12..fe28e2373 100644 --- a/app/src/main/java/io/legado/app/ui/book/searchContent/SearchContentActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/searchContent/SearchContentActivity.kt @@ -177,13 +177,7 @@ class SearchContentActivity : 2 -> HanLP.convertToTraditionalChinese(chapter.title) else -> chapter.title } - replaceContents = BookHelp.disposeContent( - chapter.title, - book.name, - book.bookUrl, - bookContent, - book.getUseReplaceRule() - ) + replaceContents = BookHelp.disposeContent(book, chapter.title, bookContent) } job.await() while (replaceContents == null) {