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

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) {
this.pageIndex = pageIndex
textChapter = ReadBook.curTextChapter
textChapter?.let { textChapter ->
nowSpeak = 0

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

Loading…
Cancel
Save