feat: 优化代码

pull/111/head
kunfei 5 years ago
parent 68fc545cfe
commit f77fe68745
  1. 9
      app/src/main/java/io/legado/app/ui/book/read/page/ChapterProvider.kt

@ -111,6 +111,7 @@ object ChapterProvider {
durY = joinBody(text, durY, textPages, pageLines, pageLengths, stringBuilder)
}
}
textPages.last().height = durY
textPages.last().text = stringBuilder.toString()
if (pageLines.size < textPages.size) {
pageLines.add(textPages.last().textLines.size)
@ -158,11 +159,13 @@ object ChapterProvider {
if (durY < visibleHeight) {
textPages.last().textLines.add(textLine)
} else {
durY = layout.getLineBottom(lineIndex) - layout.getLineTop(lineIndex)
textPages.last().height = durY
textPages.last().text = stringBuilder.toString()
stringBuilder.clear()
pageLines.add(textPages.last().textLines.size)
pageLengths.add(textPages.last().text.length)
//新页面
durY = layout.getLineBottom(lineIndex) - layout.getLineTop(lineIndex)
textPages.add(TextPage())
textPages.last().textLines.add(textLine)
}
@ -238,11 +241,13 @@ object ChapterProvider {
if (durY < visibleHeight) {
textPages.last().textLines.add(textLine)
} else {
durY = layout.getLineBottom(lineIndex) - layout.getLineTop(lineIndex)
textPages.last().height = durY
textPages.last().text = stringBuilder.toString()
stringBuilder.clear()
pageLines.add(textPages.last().textLines.size)
pageLengths.add(textPages.last().text.length)
//新页面
durY = layout.getLineBottom(lineIndex) - layout.getLineTop(lineIndex)
textPages.add(TextPage())
textPages.last().textLines.add(textLine)
}

Loading…
Cancel
Save