优化翻页

pull/357/head
gedoor 4 years ago
parent ade4632e4c
commit 16b7655cf6
  1. 16
      app/src/main/java/io/legado/app/ui/book/read/page/provider/ChapterProvider.kt

@ -45,7 +45,7 @@ object ChapterProvider {
/** /**
* 获取拆分完的章节数据 * 获取拆分完的章节数据
*/ */
suspend fun getTextChapter( fun getTextChapter(
book: Book, book: Book,
bookChapter: BookChapter, bookChapter: BookChapter,
contents: List<String>, contents: List<String>,
@ -110,7 +110,7 @@ object ChapterProvider {
) )
} }
private suspend fun setTypeImage( private fun setTypeImage(
book: Book, book: Book,
chapter: BookChapter, chapter: BookChapter,
src: String, src: String,
@ -184,14 +184,12 @@ object ChapterProvider {
pageLines: ArrayList<Int>, pageLines: ArrayList<Int>,
pageLengths: ArrayList<Int>, pageLengths: ArrayList<Int>,
stringBuilder: StringBuilder, stringBuilder: StringBuilder,
isTitle: Boolean isTitle: Boolean,
): Float { ): Float {
var durY = if (isTitle) y + titleTopSpacing else y var durY = if (isTitle) y + titleTopSpacing else y
val textPaint = if (isTitle) titlePaint else contentPaint val textPaint = if (isTitle) titlePaint else contentPaint
val layout = StaticLayout( val layout = StaticLayout(
text, textPaint, text, textPaint, visibleWidth, Layout.Alignment.ALIGN_NORMAL, 0f, 0f, true
visibleWidth,
Layout.Alignment.ALIGN_NORMAL, 0f, 0f, true
) )
for (lineIndex in 0 until layout.lineCount) { for (lineIndex in 0 until layout.lineCount) {
val textLine = TextLine(isTitle = isTitle) val textLine = TextLine(isTitle = isTitle)
@ -262,7 +260,7 @@ object ChapterProvider {
textLine: TextLine, textLine: TextLine,
words: Array<String>, words: Array<String>,
textPaint: TextPaint, textPaint: TextPaint,
desiredWidth: Float desiredWidth: Float,
) { ) {
var x = 0f var x = 0f
if (!ReadBookConfig.textFullJustify) { if (!ReadBookConfig.textFullJustify) {
@ -303,7 +301,7 @@ object ChapterProvider {
words: Array<String>, words: Array<String>,
textPaint: TextPaint, textPaint: TextPaint,
desiredWidth: Float, desiredWidth: Float,
startX: Float startX: Float,
) { ) {
if (!ReadBookConfig.textFullJustify) { if (!ReadBookConfig.textFullJustify) {
addCharsToLineLast( addCharsToLineLast(
@ -340,7 +338,7 @@ object ChapterProvider {
textLine: TextLine, textLine: TextLine,
words: Array<String>, words: Array<String>,
textPaint: TextPaint, textPaint: TextPaint,
startX: Float startX: Float,
) { ) {
var x = startX var x = startX
words.forEach { words.forEach {

Loading…
Cancel
Save