长按菜单朗读从选择开始位置一直朗读下去,未完成

pull/2176/head
kunfei 2 years ago
parent c80a0905d6
commit 55e5684256
  1. 1
      app/src/main/java/io/legado/app/service/BaseReadAloudService.kt
  2. 23
      app/src/main/java/io/legado/app/ui/book/read/page/entities/TextChapter.kt

@ -118,6 +118,7 @@ abstract class BaseReadAloudService : BaseService(),
} }
private fun newReadAloud(play: Boolean, pageIndex: Int, startPos: Int) { private fun newReadAloud(play: Boolean, pageIndex: Int, startPos: Int) {
this.pageIndex = pageIndex
textChapter = ReadBook.curTextChapter textChapter = ReadBook.curTextChapter
textChapter?.let { textChapter -> textChapter?.let { textChapter ->
nowSpeak = 0 nowSpeak = 0

@ -63,25 +63,25 @@ data class TextChapter(
} }
/** /**
* @return 获取未读文字 * 获取内容
*/ */
fun getUnRead(pageIndex: Int): String { fun getContent(): String {
val stringBuilder = StringBuilder() val stringBuilder = StringBuilder()
if (pages.isNotEmpty()) { pages.forEach {
for (index in pageIndex..pages.lastIndex) { stringBuilder.append(it.text)
stringBuilder.append(pages[index].text)
}
} }
return stringBuilder.toString() return stringBuilder.toString()
} }
/** /**
* 获取内容 * @return 获取未读文字
*/ */
fun getContent(): String { fun getUnRead(pageIndex: Int): String {
val stringBuilder = StringBuilder() val stringBuilder = StringBuilder()
pages.forEach { if (pages.isNotEmpty()) {
stringBuilder.append(it.text) for (index in pageIndex..pages.lastIndex) {
stringBuilder.append(pages[index].text)
}
} }
return stringBuilder.toString() return stringBuilder.toString()
} }
@ -93,7 +93,6 @@ data class TextChapter(
* @param startPos 从当前页什么地方开始朗读 * @param startPos 从当前页什么地方开始朗读
*/ */
fun getNeedReadAloud(pageIndex: Int, pageSplit: Boolean, startPos: Int): String { fun getNeedReadAloud(pageIndex: Int, pageSplit: Boolean, startPos: Int): String {
//todo 未完成
val stringBuilder = StringBuilder() val stringBuilder = StringBuilder()
if (pages.isNotEmpty()) { if (pages.isNotEmpty()) {
for (index in pageIndex..pages.lastIndex) { for (index in pageIndex..pages.lastIndex) {
@ -103,7 +102,7 @@ data class TextChapter(
} }
} }
} }
return stringBuilder.toString() return stringBuilder.substring(startPos).toString()
} }
/** /**

Loading…
Cancel
Save