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()