pull/32/head
kunfei 5 years ago
parent 5970604607
commit df30bcafd0
  1. 29
      app/src/main/java/io/legado/app/ui/readbook/ReadBookActivity.kt
  2. 9
      app/src/main/java/io/legado/app/ui/widget/page/ChapterProvider.kt
  3. 1
      app/src/main/java/io/legado/app/ui/widget/page/TextChapter.kt

@ -224,17 +224,10 @@ class ReadBookActivity : VMBaseActivity<ReadBookViewModel>(R.layout.activity_rea
launch {
when (bookChapter.index) {
viewModel.durChapterIndex -> {
tv_chapter_name.text = bookChapter.title
tv_chapter_name.visible()
if (!viewModel.isLocalBook) {
tv_chapter_url.text = bookChapter.url
tv_chapter_url.visible()
}
ChapterProvider.getTextChapter(content_text_view, bookChapter, content).let {
viewModel.curTextChapter = it
page_view.upContent()
read_menu.upReadProgress(it.pageSize(), viewModel.durPageIndex)
}
viewModel.curTextChapter =
ChapterProvider.getTextChapter(content_text_view, bookChapter, content)
page_view.upContent()
curChapterChange()
}
viewModel.durChapterIndex - 1 -> {
viewModel.prevTextChapter = ChapterProvider.getTextChapter(content_text_view, bookChapter, content)
@ -248,6 +241,18 @@ class ReadBookActivity : VMBaseActivity<ReadBookViewModel>(R.layout.activity_rea
}
}
private fun curChapterChange() {
viewModel.curTextChapter?.let {
tv_chapter_name.text = it.title
tv_chapter_name.visible()
if (!viewModel.isLocalBook) {
tv_chapter_url.text = it.url
tv_chapter_url.visible()
}
read_menu.upReadProgress(it.pageSize(), viewModel.durPageIndex)
}
}
override fun chapterSize(): Int {
return viewModel.chapterSize
}
@ -293,10 +298,12 @@ class ReadBookActivity : VMBaseActivity<ReadBookViewModel>(R.layout.activity_rea
override fun moveToNextChapter() {
viewModel.moveToNextChapter()
curChapterChange()
}
override fun moveToPrevChapter() {
viewModel.moveToPrevChapter()
curChapterChange()
}
override fun clickCenter() {

@ -45,8 +45,13 @@ object ChapterProvider {
pageIndex++
}
return TextChapter(bookChapter.index, bookChapter.title, textPages, pageLengths)
return TextChapter(
bookChapter.index,
bookChapter.title,
bookChapter.url,
textPages,
pageLengths
)
}
}

@ -3,6 +3,7 @@ package io.legado.app.ui.widget.page
data class TextChapter(
val position: Int,
val title: String,
val url: String,
val pages: List<TextPage>,
val pageLengths: List<Int>
) {

Loading…
Cancel
Save