pull/1592/head
kunfei 3 years ago
parent f744e19f36
commit 7095198d63
  1. 7
      app/src/main/java/io/legado/app/data/entities/BookChapter.kt

@ -80,7 +80,6 @@ data class BookChapter(
chineseConvert: Boolean = true, chineseConvert: Boolean = true,
): String { ): String {
var displayTitle = title.replace(AppPattern.rnRegex, "") var displayTitle = title.replace(AppPattern.rnRegex, "")
val mDisplayTitle = displayTitle
if (chineseConvert) { if (chineseConvert) {
when (AppConfig.chineseConverterType) { when (AppConfig.chineseConverterType) {
1 -> displayTitle = ChineseUtils.t2s(displayTitle) 1 -> displayTitle = ChineseUtils.t2s(displayTitle)
@ -91,18 +90,20 @@ data class BookChapter(
replaceRules.forEach { item -> replaceRules.forEach { item ->
if (item.pattern.isNotEmpty()) { if (item.pattern.isNotEmpty()) {
try { try {
displayTitle = if (item.isRegex) { val mDisplayTitle = if (item.isRegex) {
displayTitle.replace(item.pattern.toRegex(), item.replacement) displayTitle.replace(item.pattern.toRegex(), item.replacement)
} else { } else {
displayTitle.replace(item.pattern, item.replacement) displayTitle.replace(item.pattern, item.replacement)
} }
if (mDisplayTitle.isNotBlank()) {
displayTitle = mDisplayTitle
}
} catch (e: Exception) { } catch (e: Exception) {
appCtx.toastOnUi("${item.name}替换出错") appCtx.toastOnUi("${item.name}替换出错")
} }
} }
} }
} }
if (displayTitle.isBlank()) displayTitle = mDisplayTitle
return when { return when {
!isVip -> displayTitle !isVip -> displayTitle
isPay -> appCtx.getString(R.string.payed_title, displayTitle) isPay -> appCtx.getString(R.string.payed_title, displayTitle)

Loading…
Cancel
Save