pull/32/head
kunfei 5 years ago
parent 04376419c3
commit 945217f505
  1. 6
      app/src/main/java/io/legado/app/ui/readbook/ReadBookActivity.kt
  2. 12
      app/src/main/java/io/legado/app/ui/widget/page/PageView.kt
  3. 7
      app/src/main/java/io/legado/app/ui/widget/page/TextChapter.kt

@ -237,8 +237,8 @@ class ReadBookActivity : VMBaseActivity<ReadBookViewModel>(R.layout.activity_rea
private fun bookLoadFinish() {
viewModel.bookData.value?.let {
viewModel.loadContent(it, it.durChapterIndex)
// viewModel.loadContent(it, it.durChapterIndex + 1)
// viewModel.loadContent(it, it.durChapterIndex - 1)
viewModel.loadContent(it, it.durChapterIndex + 1)
viewModel.loadContent(it, it.durChapterIndex - 1)
}
}
@ -257,9 +257,11 @@ class ReadBookActivity : VMBaseActivity<ReadBookViewModel>(R.layout.activity_rea
}
viewModel.durChapterIndex - 1 -> {
viewModel.prevTextChapter = ChapterProvider.getTextChapter(content_text_view, bookChapter, content)
page_view.chapterLoadFinish(-1)
}
viewModel.durChapterIndex + 1 -> {
viewModel.nextTextChapter = ChapterProvider.getTextChapter(content_text_view, bookChapter, content)
page_view.chapterLoadFinish(1)
}
}
}

@ -74,10 +74,18 @@ class PageView(context: Context, attrs: AttributeSet) : FrameLayout(context, att
}
}
1 -> {
cb.textChapter()?.let {
if (cb.durChapterPos(it.pageSize()) == it.pageSize() - 1) {
nextPage?.setContent(cb.textChapter(1)?.page(0)?.text)
}
}
}
-1 -> {
cb.textChapter()?.let {
if (cb.durChapterPos(it.pageSize()) == 0) {
prevPage?.setContent(cb.textChapter(-1)?.lastPage()?.text)
}
}
}
else -> {
}

@ -13,6 +13,13 @@ data class TextChapter(
return null
}
fun lastPage(): TextPage? {
if (pages.isNotEmpty()) {
return pages[pages.lastIndex]
}
return null
}
fun pageSize(): Int {
return pages.size
}

Loading…
Cancel
Save