feat: 优化代码

pull/120/head
kunfei 5 years ago
parent a7661f191c
commit 1871fed127
  1. 6
      app/src/main/java/io/legado/app/ui/book/read/page/ChapterProvider.kt

@ -146,7 +146,7 @@ object ChapterProvider {
title.substring(layout.getLineStart(lineIndex), layout.getLineEnd(lineIndex)) title.substring(layout.getLineStart(lineIndex), layout.getLineEnd(lineIndex))
stringBuilder.append(words) stringBuilder.append(words)
textLine.text = words textLine.text = words
val desiredWidth = layout.getLineMax(lineIndex) val desiredWidth = layout.getLineWidth(lineIndex)
if (lineIndex != layout.lineCount - 1) { if (lineIndex != layout.lineCount - 1) {
val gapCount: Int = words.length - 1 val gapCount: Int = words.length - 1
val d = (visibleWidth - desiredWidth) / gapCount val d = (visibleWidth - desiredWidth) / gapCount
@ -168,7 +168,7 @@ object ChapterProvider {
textLine.text = "$words\n" textLine.text = "$words\n"
stringBuilder.append("\n") stringBuilder.append("\n")
var x = if (ReadBookConfig.titleCenter) var x = if (ReadBookConfig.titleCenter)
(visibleWidth - layout.getLineMax(lineIndex)) / 2 (visibleWidth - layout.getLineWidth(lineIndex)) / 2
else 0f else 0f
for (i in words.indices) { for (i in words.indices) {
val char = words[i].toString() val char = words[i].toString()
@ -229,7 +229,7 @@ object ChapterProvider {
text.substring(layout.getLineStart(lineIndex), layout.getLineEnd(lineIndex)) text.substring(layout.getLineStart(lineIndex), layout.getLineEnd(lineIndex))
stringBuilder.append(words) stringBuilder.append(words)
textLine.text = words textLine.text = words
val desiredWidth = layout.getLineMax(lineIndex) val desiredWidth = layout.getLineWidth(lineIndex)
if (lineIndex == 0 && layout.lineCount > 1) { if (lineIndex == 0 && layout.lineCount > 1) {
//第一行 //第一行
var x = 0f var x = 0f

Loading…
Cancel
Save