From 11de8540883f0783e1c3c0cc709edb6fce028864 Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 6 Mar 2020 09:35:33 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/ui/book/read/page/ChapterProvider.kt | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/ChapterProvider.kt b/app/src/main/java/io/legado/app/ui/book/read/page/ChapterProvider.kt index cf53a9e3f..72d648145 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/ChapterProvider.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/ChapterProvider.kt @@ -106,22 +106,9 @@ object ChapterProvider { for (lineIndex in 0 until layout.lineCount) { textPages.last().height = durY val textLine = TextLine(isTitle = isTitle) - if (durY + textPaint.textHeight < visibleHeight) { - textPages.last().textLines.add(textLine) - durY += textPaint.textHeight * lineSpacingExtra / 10f - } else { - textPages.last().text = stringBuilder.toString() - stringBuilder.clear() - pageLines.add(textPages.last().textLines.size) - pageLengths.add(textPages.last().text.length) - //新建页面 - durY = textPaint.textHeight * lineSpacingExtra / 10f - textPages.add(TextPage()) - textPages.last().textLines.add(textLine) - } - textLine.lineBottom = paddingTop + durY - lineSpacingExtra + textLine.lineBottom = paddingTop + durY + textPaint.textHeight textLine.lineBase = textLine.lineBottom - textPaint.fontMetrics.descent - textLine.lineTop = textLine.lineBottom - textPaint.textHeight + textLine.lineTop = paddingTop + durY val words = text.substring(layout.getLineStart(lineIndex), layout.getLineEnd(lineIndex)) stringBuilder.append(words) @@ -140,6 +127,19 @@ object ChapterProvider { //中间行 addCharsToLineMiddle(textLine, words, textPaint, desiredWidth, 0f) } + if (durY + textPaint.textHeight < visibleHeight) { + textPages.last().textLines.add(textLine) + durY += textPaint.textHeight * lineSpacingExtra / 10f + } else { + textPages.last().text = stringBuilder.toString() + stringBuilder.clear() + pageLines.add(textPages.last().textLines.size) + pageLengths.add(textPages.last().text.length) + //新建页面 + durY = textPaint.textHeight * lineSpacingExtra / 10f + textPages.add(TextPage()) + textPages.last().textLines.add(textLine) + } } durY += textPaint.textHeight * paragraphSpacing / 10f return durY