pull/46/head
kunfei 5 years ago
parent 50c8da23d7
commit 39dd84369c
  1. 7
      app/src/main/java/io/legado/app/help/BookHelp.kt
  2. 9
      app/src/main/java/io/legado/app/model/webbook/BookContent.kt
  3. 5
      app/src/main/java/io/legado/app/ui/book/read/ReadBookViewModel.kt

@ -136,7 +136,9 @@ object BookHelp {
var replaceRules: List<ReplaceRule> = arrayListOf() var replaceRules: List<ReplaceRule> = arrayListOf()
fun disposeContent( fun disposeContent(
name: String, origin: String?, title: String,
name: String,
origin: String?,
content: String, content: String,
enableReplace: Boolean enableReplace: Boolean
): String { ): String {
@ -150,6 +152,9 @@ object BookHelp {
} }
} }
} }
if (!content.substringBefore("\n").contains(title)) {
c = title + "\n" + c
}
for (item in replaceRules) { for (item in replaceRules) {
item.pattern.let { item.pattern.let {
if (it.isNotEmpty()) { if (it.isNotEmpty()) {

@ -94,15 +94,6 @@ object BookContent {
content.append(item.content) 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() return content.toString()
} }

@ -225,10 +225,11 @@ class ReadBookViewModel(application: Application) : BaseViewModel(application) {
execute { execute {
if (chapter.index in durChapterIndex - 1..durChapterIndex + 1) { if (chapter.index in durChapterIndex - 1..durChapterIndex + 1) {
val c = BookHelp.disposeContent( val c = BookHelp.disposeContent(
bookData.value?.name ?: "", chapter.title,
bookData.value!!.name,
webBook?.bookSource?.bookSourceUrl, webBook?.bookSource?.bookSourceUrl,
content, content,
bookData.value?.useReplaceRule ?: true bookData.value!!.useReplaceRule
) )
callBack?.contentLoadFinish(chapter, c) callBack?.contentLoadFinish(chapter, c)
} }

Loading…
Cancel
Save