pull/51/head
kunfei 5 years ago
parent 92598bca76
commit 5792856a75
  1. 2
      app/src/main/java/io/legado/app/service/help/ReadBook.kt
  2. 14
      app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt
  3. 7
      app/src/main/java/io/legado/app/ui/book/read/ReadMenu.kt
  4. 4
      app/src/main/java/io/legado/app/ui/widget/page/DataSource.kt
  5. 18
      app/src/main/java/io/legado/app/ui/widget/page/PageView.kt
  6. 6
      app/src/main/java/io/legado/app/ui/widget/page/TextPageFactory.kt

@ -85,7 +85,7 @@ object ReadBook {
}
}
fun moveToPrevChapter(upContent: Boolean, toLast: Boolean): Boolean {
fun moveToPrevChapter(upContent: Boolean, toLast: Boolean = true): Boolean {
if (durChapterIndex > 0) {
durPageIndex = if (toLast) prevTextChapter?.lastIndex() ?: 0 else 0
durChapterIndex--

@ -339,20 +339,6 @@ class ReadBookActivity : VMBaseActivity<ReadBookViewModel>(R.layout.activity_boo
}
}
/**
* 下一页
*/
override fun moveToNextChapter(upContent: Boolean): Boolean {
return ReadBook.moveToNextChapter(upContent)
}
/**
* 上一页
*/
override fun moveToPrevChapter(upContent: Boolean, last: Boolean): Boolean {
return ReadBook.moveToPrevChapter(upContent, last)
}
override fun clickCenter() {
if (BaseReadAloudService.isRun) {
showReadAloudDialog()

@ -13,6 +13,7 @@ import io.legado.app.R
import io.legado.app.constant.PreferKey
import io.legado.app.lib.theme.accentColor
import io.legado.app.lib.theme.buttonDisabledColor
import io.legado.app.service.help.ReadBook
import io.legado.app.utils.*
import kotlinx.android.synthetic.main.view_read_menu.view.*
import org.jetbrains.anko.sdk27.listeners.onClick
@ -148,10 +149,10 @@ class ReadMenu : FrameLayout {
}
//上一章
tv_pre.onClick { callBack?.moveToPrevChapter(upContent = true, last = false) }
tv_pre.onClick { ReadBook.moveToPrevChapter(upContent = true, toLast = false) }
//下一章
tv_next.onClick { callBack?.moveToNextChapter(true) }
tv_next.onClick { ReadBook.moveToNextChapter(true) }
//目录
ll_catalog.onClick {
@ -245,8 +246,6 @@ class ReadMenu : FrameLayout {
interface CallBack {
fun autoPage()
fun skipToPage(page: Int)
fun moveToPrevChapter(upContent: Boolean, last: Boolean): Boolean
fun moveToNextChapter(upContent: Boolean): Boolean
fun openReplaceRule()
fun openChapterList()
fun showReadStyle()

@ -21,8 +21,4 @@ interface DataSource {
fun hasPrevChapter(): Boolean
fun moveToNextChapter()
fun moveToPrevChapter()
}

@ -220,14 +220,6 @@ class PageView(context: Context, attrs: AttributeSet) :
return false
}
override fun moveToNextChapter() {
callBack?.moveToNextChapter(false)
}
override fun moveToPrevChapter() {
callBack?.moveToPrevChapter(false)
}
override fun scrollToLine(line: Int) {
if (isScrollDelegate) {
callBack?.textChapter()?.let {
@ -262,16 +254,6 @@ class PageView(context: Context, attrs: AttributeSet) :
*/
fun loadContent(index: Int)
/**
* 下一章
*/
fun moveToNextChapter(upContent: Boolean): Boolean
/**
* 上一章
*/
fun moveToPrevChapter(upContent: Boolean, last: Boolean = true): Boolean
/**
* 保存页数
*/

@ -1,5 +1,7 @@
package io.legado.app.ui.widget.page
import io.legado.app.service.help.ReadBook
class TextPageFactory(dataSource: DataSource) : PageFactory<TextPage>(dataSource) {
override fun hasPrev(): Boolean = with(dataSource) {
@ -43,7 +45,7 @@ class TextPageFactory(dataSource: DataSource) : PageFactory<TextPage>(dataSource
if (getCurrentChapter()?.isLastIndex(pageIndex) == true
|| isScrollDelegate
) {
moveToNextChapter()
ReadBook.moveToNextChapter(false)
} else {
setPageIndex(pageIndex.plus(1))
}
@ -55,7 +57,7 @@ class TextPageFactory(dataSource: DataSource) : PageFactory<TextPage>(dataSource
override fun moveToPrevious(): Boolean = with(dataSource) {
return if (hasPrev()) {
if (pageIndex <= 0 || isScrollDelegate) {
moveToPrevChapter()
ReadBook.moveToPrevChapter(false)
} else {
setPageIndex(pageIndex.minus(1))
}

Loading…
Cancel
Save