feat: 优化

pull/201/head
kunfei 5 years ago
parent 93541d8131
commit bf27baccd1
  1. 1
      app/src/main/java/io/legado/app/help/BookHelp.kt
  2. 4
      app/src/main/java/io/legado/app/service/BaseReadAloudService.kt

@ -243,5 +243,6 @@ object BookHelp {
} }
return c return c
.replace("\\s*\\n+\\s*".toRegex(), "\n${ReadBookConfig.bodyIndent}") .replace("\\s*\\n+\\s*".toRegex(), "\n${ReadBookConfig.bodyIndent}")
.replace("[\\n\\s]+$".toRegex(), "") //移除尾部空行
} }
} }

@ -111,18 +111,14 @@ abstract class BaseReadAloudService : BaseService(),
if (getPrefBoolean(PreferKey.readAloudByPage)) { if (getPrefBoolean(PreferKey.readAloudByPage)) {
for (index in pageIndex..textChapter.lastIndex()) { for (index in pageIndex..textChapter.lastIndex()) {
textChapter.page(index)?.text?.split("\n")?.let { textChapter.page(index)?.text?.split("\n")?.let {
if (it.isNotEmpty()) {
contentList.addAll(it) contentList.addAll(it)
} }
} }
}
} else { } else {
textChapter.getUnRead(pageIndex).split("\n").forEach { textChapter.getUnRead(pageIndex).split("\n").forEach {
if (it.isNotEmpty()) {
contentList.add(it) contentList.add(it)
} }
} }
}
if (play) play() if (play) play()
} ?: stopSelf() } ?: stopSelf()
} ?: stopSelf() } ?: stopSelf()

Loading…
Cancel
Save