pull/1606/head
kunfei 3 years ago
parent 7169c62369
commit b813947d50
  1. 2
      app/src/main/java/io/legado/app/data/entities/BookChapter.kt
  2. 16
      app/src/main/java/io/legado/app/help/ContentProcessor.kt

@ -74,7 +74,7 @@ data class BookChapter(
@Suppress("unused") @Suppress("unused")
fun getDisplayTitle( fun getDisplayTitle(
replaceRules: Array<ReplaceRule>? = null, replaceRules: List<ReplaceRule>? = null,
useReplace: Boolean = true, useReplace: Boolean = true,
chineseConvert: Boolean = true, chineseConvert: Boolean = true,
): String { ): String {

@ -9,6 +9,7 @@ import io.legado.app.data.entities.ReplaceRule
import io.legado.app.utils.toastOnUi import io.legado.app.utils.toastOnUi
import splitties.init.appCtx import splitties.init.appCtx
import java.lang.ref.WeakReference import java.lang.ref.WeakReference
import java.util.concurrent.CopyOnWriteArrayList
import java.util.regex.Pattern import java.util.regex.Pattern
class ContentProcessor private constructor( class ContentProcessor private constructor(
@ -37,14 +38,13 @@ class ContentProcessor private constructor(
} }
private val titleReplaceRules = arrayListOf<ReplaceRule>() private val titleReplaceRules = CopyOnWriteArrayList<ReplaceRule>()
private val contentReplaceRules = arrayListOf<ReplaceRule>() private val contentReplaceRules = CopyOnWriteArrayList<ReplaceRule>()
init { init {
upReplaceRules() upReplaceRules()
} }
@Synchronized
fun upReplaceRules() { fun upReplaceRules() {
titleReplaceRules.run { titleReplaceRules.run {
clear() clear()
@ -56,14 +56,12 @@ class ContentProcessor private constructor(
} }
} }
@Synchronized fun getTitleReplaceRules(): List<ReplaceRule> {
fun getTitleReplaceRules(): Array<ReplaceRule> { return titleReplaceRules
return titleReplaceRules.toTypedArray()
} }
@Synchronized fun getContentReplaceRules(): List<ReplaceRule> {
fun getContentReplaceRules(): Array<ReplaceRule> { return contentReplaceRules
return contentReplaceRules.toTypedArray()
} }
fun getContent( fun getContent(

Loading…
Cancel
Save