feat: 优化代码

pull/134/head^2
kunfei 5 years ago
parent a235f4c641
commit 936087e5d1
  1. 5
      app/src/main/java/io/legado/app/ui/book/read/page/ChapterProvider.kt

@ -115,10 +115,11 @@ object ChapterProvider {
addCharsToLineFirst(textLine, words, textPaint, desiredWidth)
} else if (lineIndex == layout.lineCount - 1) {
//最后一行
stringBuilder.append("\n")
val x = if (isTitle && ReadBookConfig.titleMode == 1)
(visibleWidth - layout.getLineWidth(lineIndex)) / 2
else 0f
addCharsToLineLast(textLine, words, stringBuilder, textPaint, x)
addCharsToLineLast(textLine, words, textPaint, x)
} else {
//中间行
addCharsToLineMiddle(textLine, words, textPaint, desiredWidth, 0f)
@ -205,11 +206,9 @@ object ChapterProvider {
private fun addCharsToLineLast(
textLine: TextLine,
words: String,
stringBuilder: StringBuilder,
textPaint: TextPaint,
startX: Float
) {
stringBuilder.append("\n")
textLine.text = "$words\n"
var x = startX
words.toStringArray().forEach {

Loading…
Cancel
Save