feat: 优化代码

pull/106/head
kunfei 5 years ago
parent 27d40c5cdf
commit 861f04c56a
  1. 8
      app/src/main/java/io/legado/app/ui/book/read/page/ChapterProvider.kt

@ -139,6 +139,9 @@ object ChapterProvider {
) )
} }
/**
* 标题
*/
private fun joinTitle( private fun joinTitle(
title: String, title: String,
y: Int, y: Int,
@ -218,6 +221,9 @@ object ChapterProvider {
return durY return durY
} }
/**
* 正文
*/
private fun joinBody( private fun joinBody(
text: String, text: String,
y: Int, y: Int,
@ -255,6 +261,7 @@ object ChapterProvider {
) )
var words = var words =
text.substring(layout.getLineStart(lineIndex), layout.getLineEnd(lineIndex)) text.substring(layout.getLineStart(lineIndex), layout.getLineEnd(lineIndex))
stringBuilder.append(words)
val desiredWidth = layout.getLineMax(lineIndex) val desiredWidth = layout.getLineMax(lineIndex)
if (lineIndex == 0 && layout.lineCount > 1) { if (lineIndex == 0 && layout.lineCount > 1) {
//第一行 //第一行
@ -289,6 +296,7 @@ object ChapterProvider {
} }
} else if (lineIndex == layout.lineCount - 1) { } else if (lineIndex == layout.lineCount - 1) {
//最后一行 //最后一行
stringBuilder.append("\n")
var x = 0 var x = 0
for (i in words.indices) { for (i in words.indices) {
val char = words[i].toString() val char = words[i].toString()

Loading…
Cancel
Save