pull/898/head
gedoor 4 years ago
parent c6dcd01fc3
commit 19869854ba
  1. 13
      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<String>()

Loading…
Cancel
Save