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

Loading…
Cancel
Save