feat: 优化

pull/201/head
kunfei 5 years ago
parent 3cb286c5b2
commit 3609f691f3
  1. 8
      app/src/main/java/io/legado/app/ui/book/read/page/ChapterProvider.kt

@ -189,11 +189,11 @@ object ChapterProvider {
val gapCount: Int = words.length - 1 val gapCount: Int = words.length - 1
val d = (visibleWidth - desiredWidth) / gapCount val d = (visibleWidth - desiredWidth) / gapCount
var x = startX var x = startX
for ((i, char) in words.toStringArray().withIndex()) { words.toStringArray().forEachIndexed { index, s ->
val cw = StaticLayout.getDesiredWidth(char, textPaint) val cw = StaticLayout.getDesiredWidth(s, textPaint)
val x1 = if (i != words.lastIndex) (x + cw + d) else (x + cw) val x1 = if (index != words.lastIndex) (x + cw + d) else (x + cw)
textLine.addTextChar( textLine.addTextChar(
charData = char, charData = s,
start = paddingLeft + x, start = paddingLeft + x,
end = paddingLeft + x1 end = paddingLeft + x1
) )

Loading…
Cancel
Save