pull/32/head
kunfei 5 years ago
parent 70f1082bba
commit fae1bb05f5
  1. 12
      app/src/main/java/io/legado/app/ui/widget/page/ChapterProvider.kt

@ -35,12 +35,16 @@ object ChapterProvider {
} }
} }
textView.text = spannableStringBuilder textView.text = spannableStringBuilder
pageLengths.add(textView.getCharNum()) val lastCharNum = textView.getCharNum()
if (lastCharNum == 0) {
break
} else {
pageLengths.add(lastCharNum)
textPages.add( textPages.add(
TextPage( TextPage(
index = pageIndex, index = pageIndex,
text = spannableStringBuilder.delete( text = spannableStringBuilder.delete(
pageLengths[pageIndex], lastCharNum,
spannableStringBuilder.length spannableStringBuilder.length
), ),
title = bookChapter.title, title = bookChapter.title,
@ -48,10 +52,10 @@ object ChapterProvider {
chapterIndex = bookChapter.index chapterIndex = bookChapter.index
) )
) )
surplusText = surplusText.substring(pageLengths[pageIndex]) surplusText = surplusText.substring(lastCharNum)
pageIndex++ pageIndex++
} }
}
for (item in textPages) { for (item in textPages) {
item.pageSize = textPages.size item.pageSize = textPages.size
} }

Loading…
Cancel
Save