From 19869854baa77a2717d900f4f7749288529dc3dc Mon Sep 17 00:00:00 2001 From: gedoor Date: Sun, 14 Mar 2021 15:44:58 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/legado/app/help/ContentProcessor.kt | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) 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 b8787242b..f0c44273a 100644 --- a/app/src/main/java/io/legado/app/help/ContentProcessor.kt +++ b/app/src/main/java/io/legado/app/help/ContentProcessor.kt @@ -5,8 +5,6 @@ import io.legado.app.data.appDb import io.legado.app.data.entities.Book import io.legado.app.data.entities.ReplaceRule import io.legado.app.utils.toastOnUi -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.withContext import splitties.init.appCtx class ContentProcessor(private val bookName: String, private val bookOrigin: String) { @@ -23,7 +21,8 @@ class ContentProcessor(private val bookName: String, private val bookOrigin: Str replaceRules.addAll(appDb.replaceRuleDao.findEnabledByScope(bookName, bookOrigin)) } - suspend fun getContent( + @Synchronized + fun getContent( book: Book, title: String, //已经经过简繁转换 content: String, @@ -41,9 +40,7 @@ class ContentProcessor(private val bookName: String, private val bookOrigin: Str content1.replace(item.pattern, item.replacement) } } catch (e: Exception) { - withContext(Dispatchers.Main) { - appCtx.toastOnUi("${item.name}替换出错") - } + appCtx.toastOnUi("${item.name}替换出错") } } } @@ -58,9 +55,7 @@ class ContentProcessor(private val bookName: String, private val bookOrigin: Str 2 -> content1 = HanLP.convertToTraditionalChinese(content1) } } catch (e: Exception) { - withContext(Dispatchers.Main) { - appCtx.toastOnUi("简繁转换出错") - } + appCtx.toastOnUi("简繁转换出错") } } val contents = arrayListOf()