From b813947d5038da7aa57300f69855783624dfc485 Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 11 Feb 2022 14:39:00 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io/legado/app/data/entities/BookChapter.kt | 2 +- .../java/io/legado/app/help/ContentProcessor.kt | 16 +++++++--------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/io/legado/app/data/entities/BookChapter.kt b/app/src/main/java/io/legado/app/data/entities/BookChapter.kt index 8258151dd..9afff1941 100644 --- a/app/src/main/java/io/legado/app/data/entities/BookChapter.kt +++ b/app/src/main/java/io/legado/app/data/entities/BookChapter.kt @@ -74,7 +74,7 @@ data class BookChapter( @Suppress("unused") fun getDisplayTitle( - replaceRules: Array? = null, + replaceRules: List? = null, useReplace: Boolean = true, chineseConvert: Boolean = true, ): String { diff --git a/app/src/main/java/io/legado/app/help/ContentProcessor.kt b/app/src/main/java/io/legado/app/help/ContentProcessor.kt index e49ec5c30..7f2d8eecc 100644 --- a/app/src/main/java/io/legado/app/help/ContentProcessor.kt +++ b/app/src/main/java/io/legado/app/help/ContentProcessor.kt @@ -9,6 +9,7 @@ import io.legado.app.data.entities.ReplaceRule import io.legado.app.utils.toastOnUi import splitties.init.appCtx import java.lang.ref.WeakReference +import java.util.concurrent.CopyOnWriteArrayList import java.util.regex.Pattern class ContentProcessor private constructor( @@ -37,14 +38,13 @@ class ContentProcessor private constructor( } - private val titleReplaceRules = arrayListOf() - private val contentReplaceRules = arrayListOf() + private val titleReplaceRules = CopyOnWriteArrayList() + private val contentReplaceRules = CopyOnWriteArrayList() init { upReplaceRules() } - @Synchronized fun upReplaceRules() { titleReplaceRules.run { clear() @@ -56,14 +56,12 @@ class ContentProcessor private constructor( } } - @Synchronized - fun getTitleReplaceRules(): Array { - return titleReplaceRules.toTypedArray() + fun getTitleReplaceRules(): List { + return titleReplaceRules } - @Synchronized - fun getContentReplaceRules(): Array { - return contentReplaceRules.toTypedArray() + fun getContentReplaceRules(): List { + return contentReplaceRules } fun getContent(