From 39dd84369c35439a3fb6bbeb3cfc5480cbdfd4fc Mon Sep 17 00:00:00 2001 From: kunfei Date: Sun, 3 Nov 2019 18:33:54 +0800 Subject: [PATCH] up --- app/src/main/java/io/legado/app/help/BookHelp.kt | 7 ++++++- .../main/java/io/legado/app/model/webbook/BookContent.kt | 9 --------- .../java/io/legado/app/ui/book/read/ReadBookViewModel.kt | 5 +++-- 3 files changed, 9 insertions(+), 12 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 53eae7501..33b3edaea 100644 --- a/app/src/main/java/io/legado/app/help/BookHelp.kt +++ b/app/src/main/java/io/legado/app/help/BookHelp.kt @@ -136,7 +136,9 @@ object BookHelp { var replaceRules: List = arrayListOf() fun disposeContent( - name: String, origin: String?, + title: String, + name: String, + origin: String?, content: String, enableReplace: Boolean ): String { @@ -150,6 +152,9 @@ object BookHelp { } } } + if (!content.substringBefore("\n").contains(title)) { + c = title + "\n" + c + } for (item in replaceRules) { item.pattern.let { if (it.isNotEmpty()) { diff --git a/app/src/main/java/io/legado/app/model/webbook/BookContent.kt b/app/src/main/java/io/legado/app/model/webbook/BookContent.kt index 33f1083df..c6a520aa7 100644 --- a/app/src/main/java/io/legado/app/model/webbook/BookContent.kt +++ b/app/src/main/java/io/legado/app/model/webbook/BookContent.kt @@ -94,15 +94,6 @@ object BookContent { content.append(item.content) } } - if (content.isNotEmpty()) { - SourceDebug.printLog(bookSource.bookSourceUrl, "┌获取章节名称") - SourceDebug.printLog(bookSource.bookSourceUrl, "└${bookChapter.title}") - SourceDebug.printLog(bookSource.bookSourceUrl, "┌获取正文内容") - if (!content[0].toString().startsWith(bookChapter.title)) { - content - .insert(0, "└\n") - } - } return content.toString() } diff --git a/app/src/main/java/io/legado/app/ui/book/read/ReadBookViewModel.kt b/app/src/main/java/io/legado/app/ui/book/read/ReadBookViewModel.kt index e294c0153..3403a741a 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/ReadBookViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/ReadBookViewModel.kt @@ -225,10 +225,11 @@ class ReadBookViewModel(application: Application) : BaseViewModel(application) { execute { if (chapter.index in durChapterIndex - 1..durChapterIndex + 1) { val c = BookHelp.disposeContent( - bookData.value?.name ?: "", + chapter.title, + bookData.value!!.name, webBook?.bookSource?.bookSourceUrl, content, - bookData.value?.useReplaceRule ?: true + bookData.value!!.useReplaceRule ) callBack?.contentLoadFinish(chapter, c) }