优化
This commit is contained in:
@@ -415,7 +415,7 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at
|
||||
if (compareStart >= 0 && compareEnd <= 0) {
|
||||
builder.append(textChar.charData)
|
||||
if (
|
||||
textLine.isLastLine
|
||||
textLine.isParagraphEnd
|
||||
&& charIndex == textLine.charSize - 1
|
||||
&& compareEnd != 0
|
||||
) {
|
||||
|
||||
@@ -286,7 +286,7 @@ class ReadView(context: Context, attrs: AttributeSet) :
|
||||
var lineEnd = lineIndex
|
||||
for (index in lineIndex - 1 downTo 0) {
|
||||
val textLine = page.getLine(index)
|
||||
if (textLine.isLastLine) {
|
||||
if (textLine.isParagraphEnd) {
|
||||
break
|
||||
} else {
|
||||
stringBuilder.insert(0, textLine.text)
|
||||
@@ -298,7 +298,7 @@ class ReadView(context: Context, attrs: AttributeSet) :
|
||||
val textLine = page.getLine(index)
|
||||
stringBuilder.append(textLine.text)
|
||||
lineEnd += 1
|
||||
if (textLine.isLastLine) {
|
||||
if (textLine.isParagraphEnd) {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ data class TextLine(
|
||||
var lineBase: Float = 0f,
|
||||
var lineBottom: Float = 0f,
|
||||
val isTitle: Boolean = false,
|
||||
var isLastLine: Boolean = false,
|
||||
var isParagraphEnd: Boolean = false,
|
||||
var isReadAloud: Boolean = false,
|
||||
var isImage: Boolean = false
|
||||
) {
|
||||
|
||||
@@ -128,14 +128,14 @@ data class TextPage(
|
||||
for ((index, textLine) in textLines.withIndex()) {
|
||||
if (aloudSpanStart > lineStart && aloudSpanStart < lineStart + textLine.text.length) {
|
||||
for (i in index - 1 downTo 0) {
|
||||
if (textLines[i].isLastLine) {
|
||||
if (textLines[i].isParagraphEnd) {
|
||||
break
|
||||
} else {
|
||||
textLines[i].isReadAloud = true
|
||||
}
|
||||
}
|
||||
for (i in index until textLines.size) {
|
||||
if (textLines[i].isLastLine) {
|
||||
if (textLines[i].isParagraphEnd) {
|
||||
textLines[i].isReadAloud = true
|
||||
break
|
||||
} else {
|
||||
|
||||
@@ -347,7 +347,7 @@ object ChapterProvider {
|
||||
lineIndex == layout.lineCount - 1 -> {
|
||||
//最后一行
|
||||
textLine.text = words
|
||||
textLine.isLastLine = true
|
||||
textLine.isParagraphEnd = true
|
||||
//标题x轴居中
|
||||
val startX =
|
||||
if (isTitle && ReadBookConfig.titleMode == 1 || isTitleWithNoContent || isVolumeTitle)
|
||||
@@ -377,7 +377,7 @@ object ChapterProvider {
|
||||
}
|
||||
}
|
||||
stringBuilder.append(words)
|
||||
if (textLine.isLastLine) {
|
||||
if (textLine.isParagraphEnd) {
|
||||
stringBuilder.append("\n")
|
||||
}
|
||||
textPages.last().textLines.add(textLine)
|
||||
|
||||
Reference in New Issue
Block a user