添加重新分段功能,针对每本书,在菜单里

pull/443/head
gedoor 4 years ago
parent 703e503810
commit 3ba16a7727
  1. 21
      app/src/main/java/io/legado/app/help/BookHelp.kt
  2. 8
      app/src/main/java/io/legado/app/service/help/ReadBook.kt
  3. 8
      app/src/main/java/io/legado/app/ui/book/searchContent/SearchContentActivity.kt

@ -318,23 +318,24 @@ object BookHelp {
}
suspend fun disposeContent(
book: Book,
title: String,
name: String,
origin: String?,
content: String,
enableReplace: Boolean,
): List<String> {
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!!)
}
}
}

@ -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 =

@ -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) {

Loading…
Cancel
Save