pull/32/head
kunfei 5 years ago
parent 316b7bbd59
commit 8fdf876456
  1. 32
      app/src/main/java/io/legado/app/ui/readbook/ReadBookActivity.kt
  2. 4
      app/src/main/java/io/legado/app/ui/readbook/ReadMenu.kt
  3. 8
      app/src/main/java/io/legado/app/ui/widget/page/PageView.kt

@ -372,21 +372,31 @@ class ReadBookActivity : VMBaseActivity<ReadBookViewModel>(R.layout.activity_rea
/**
* 下一页
*/
override fun moveToNextChapter() {
viewModel.durPageIndex = 0
viewModel.moveToNextChapter()
viewModel.saveRead()
curChapterChanged()
override fun moveToNextChapter(): Boolean {
return if (viewModel.durChapterIndex < viewModel.chapterSize - 1) {
viewModel.durPageIndex = 0
viewModel.moveToNextChapter()
viewModel.saveRead()
curChapterChanged()
true
} else {
false
}
}
/**
* 上一页
*/
override fun moveToPrevChapter(last: Boolean) {
viewModel.durPageIndex = if (last) viewModel.prevTextChapter?.lastIndex() ?: 0 else 0
viewModel.moveToPrevChapter()
viewModel.saveRead()
curChapterChanged()
override fun moveToPrevChapter(last: Boolean): Boolean {
return if (viewModel.durChapterIndex > 0) {
viewModel.durPageIndex = if (last) viewModel.prevTextChapter?.lastIndex() ?: 0 else 0
viewModel.moveToPrevChapter()
viewModel.saveRead()
curChapterChanged()
true
} else {
false
}
}
override fun clickCenter() {
@ -557,7 +567,7 @@ class ReadBookActivity : VMBaseActivity<ReadBookViewModel>(R.layout.activity_rea
page_view.upContent()
viewModel.saveRead()
}
2 -> moveToNextChapter()
2 -> if (moveToNextChapter()) ReadAloudService.stop(this)
-1 -> {
if (viewModel.durPageIndex > 0) {
viewModel.durPageIndex = viewModel.durPageIndex - 1

@ -249,8 +249,8 @@ class ReadMenu : FrameLayout {
interface CallBack {
fun autoPage()
fun skipToPage(page: Int)
fun moveToPrevChapter(last: Boolean)
fun moveToNextChapter()
fun moveToPrevChapter(last: Boolean): Boolean
fun moveToNextChapter(): Boolean
fun openReplaceRule()
fun openChapterList()
fun showReadStyle()

@ -220,14 +220,14 @@ class PageView(context: Context, attrs: AttributeSet) : FrameLayout(context, att
fun loadContent(index: Int)
/**
* 下一
* 下一
*/
fun moveToNextChapter()
fun moveToNextChapter(): Boolean
/**
* 上一
* 上一
*/
fun moveToPrevChapter(last: Boolean = true)
fun moveToPrevChapter(last: Boolean = true): Boolean
/**
* 保存页数

Loading…
Cancel
Save