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

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

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

Loading…
Cancel
Save