优化
This commit is contained in:
@@ -396,9 +396,10 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at
|
|||||||
val compareEnd = pos.compare(selectEnd)
|
val compareEnd = pos.compare(selectEnd)
|
||||||
if (compareStart >= 0 && compareEnd <= 0) {
|
if (compareStart >= 0 && compareEnd <= 0) {
|
||||||
builder.append(textChar.charData)
|
builder.append(textChar.charData)
|
||||||
if (compareEnd != 0
|
if (
|
||||||
|
textLine.isLastLine
|
||||||
&& charIndex == textLine.charSize - 1
|
&& charIndex == textLine.charSize - 1
|
||||||
&& textLine.text.endsWith("\n")
|
&& compareEnd != 0
|
||||||
) {
|
) {
|
||||||
builder.append("\n")
|
builder.append("\n")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -276,12 +276,12 @@ class ReadView(context: Context, attrs: AttributeSet) :
|
|||||||
private fun onLongPress() {
|
private fun onLongPress() {
|
||||||
kotlin.runCatching {
|
kotlin.runCatching {
|
||||||
curPage.selectText(startX, startY) { relativePage, lineIndex, charIndex ->
|
curPage.selectText(startX, startY) { relativePage, lineIndex, charIndex ->
|
||||||
|
isTextSelected = true
|
||||||
|
firstRelativePage = relativePage
|
||||||
|
firstLineIndex = lineIndex
|
||||||
|
firstCharIndex = charIndex
|
||||||
val page = curPage.relativePage(relativePage)
|
val page = curPage.relativePage(relativePage)
|
||||||
with(page) {
|
with(page) {
|
||||||
isTextSelected = true
|
|
||||||
firstRelativePage = relativePage
|
|
||||||
firstLineIndex = lineIndex
|
|
||||||
firstCharIndex = charIndex
|
|
||||||
var lineStart = lineIndex
|
var lineStart = lineIndex
|
||||||
var lineEnd = lineIndex
|
var lineEnd = lineIndex
|
||||||
var start: Int
|
var start: Int
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ data class TextLine(
|
|||||||
var lineBase: Float = 0f,
|
var lineBase: Float = 0f,
|
||||||
var lineBottom: Float = 0f,
|
var lineBottom: Float = 0f,
|
||||||
val isTitle: Boolean = false,
|
val isTitle: Boolean = false,
|
||||||
|
var isLastLine: Boolean = false,
|
||||||
var isReadAloud: Boolean = false,
|
var isReadAloud: Boolean = false,
|
||||||
var isImage: Boolean = false
|
var isImage: Boolean = false
|
||||||
) {
|
) {
|
||||||
|
|||||||
@@ -331,7 +331,6 @@ object ChapterProvider {
|
|||||||
val words =
|
val words =
|
||||||
text.substring(layout.getLineStart(lineIndex), layout.getLineEnd(lineIndex))
|
text.substring(layout.getLineStart(lineIndex), layout.getLineEnd(lineIndex))
|
||||||
val desiredWidth = layout.getLineWidth(lineIndex)
|
val desiredWidth = layout.getLineWidth(lineIndex)
|
||||||
var isLastLine = false
|
|
||||||
when {
|
when {
|
||||||
lineIndex == 0 && layout.lineCount > 1 && !isTitle -> {
|
lineIndex == 0 && layout.lineCount > 1 && !isTitle -> {
|
||||||
//第一行 非标题
|
//第一行 非标题
|
||||||
@@ -347,8 +346,8 @@ object ChapterProvider {
|
|||||||
}
|
}
|
||||||
lineIndex == layout.lineCount - 1 -> {
|
lineIndex == layout.lineCount - 1 -> {
|
||||||
//最后一行
|
//最后一行
|
||||||
textLine.text = "$words\n"
|
textLine.text = words
|
||||||
isLastLine = true
|
textLine.isLastLine = true
|
||||||
//标题x轴居中
|
//标题x轴居中
|
||||||
val startX =
|
val startX =
|
||||||
if (isTitle && ReadBookConfig.titleMode == 1 || isTitleWithNoContent || isVolumeTitle)
|
if (isTitle && ReadBookConfig.titleMode == 1 || isTitleWithNoContent || isVolumeTitle)
|
||||||
@@ -378,7 +377,7 @@ object ChapterProvider {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
stringBuilder.append(words)
|
stringBuilder.append(words)
|
||||||
if (isLastLine) stringBuilder.append("\n")
|
if (textLine.isLastLine) stringBuilder.append("\n")
|
||||||
textPages.last().textLines.add(textLine)
|
textPages.last().textLines.add(textLine)
|
||||||
textLine.upTopBottom(durY, textPaint)
|
textLine.upTopBottom(durY, textPaint)
|
||||||
durY += textPaint.textHeight * lineSpacingExtra
|
durY += textPaint.textHeight * lineSpacingExtra
|
||||||
|
|||||||
Reference in New Issue
Block a user