pull/32/head
kunfei 5 years ago
parent 7acdacb274
commit 15f12da6c4
  1. 6
      app/src/main/java/io/legado/app/ui/widget/page/ChapterProvider.kt
  2. 6
      app/src/main/java/io/legado/app/ui/widget/page/ContentView.kt
  3. 3
      app/src/main/java/io/legado/app/ui/widget/page/TextPage.kt
  4. 6
      app/src/main/java/io/legado/app/ui/widget/page/TextPageFactory.kt

@ -31,7 +31,11 @@ object ChapterProvider {
textPages.add(
TextPage(
pageIndex,
spannableStringBuilder.delete(pageLengths[pageIndex], spannableStringBuilder.length)
spannableStringBuilder.delete(
pageLengths[pageIndex],
spannableStringBuilder.length
),
bookChapter.title
)
)
surplusText = surplusText.substring(pageLengths[pageIndex])

@ -79,13 +79,9 @@ class ContentView : FrameLayout {
tv_top_right.text = context.getString(R.string.battery_show, battery)
}
fun setChapterTile(tile: String) {
tv_bottom_left.text = tile
}
fun setContent(page: TextPage?) {
content_text_view.text = page?.text
tv_bottom_left.text = page?.title
tv_bottom_right.text = page?.index?.toString()
}
}

@ -2,5 +2,6 @@ package io.legado.app.ui.widget.page
data class TextPage(
val index: Int,
val text: CharSequence
val text: CharSequence,
val title: String
)

@ -55,17 +55,17 @@ class TextPageFactory private constructor(dataSource: DataSource) :
override fun currentPage(): TextPage? {
return dataSource.getCurrentChapter()?.page(index)
?: TextPage(index, "index:$index")
?: TextPage(index, "index:$index", "index:$index")
}
override fun nextPage(): TextPage? {
return dataSource.getCurrentChapter()?.page(index + 1)
?: TextPage(index + 1, "index:${index + 1}")
?: TextPage(index + 1, "index:${index + 1}", "index:${index + 1}")
}
override fun previousPage(): TextPage? {
return dataSource.getCurrentChapter()?.page(index - 1)
?: TextPage(index - 1, "index:${index - 1}")
?: TextPage(index - 1, "index:${index - 1}", "index:${index - 1}")
}

Loading…
Cancel
Save