|
|
@@ -45,6 +45,7 @@ class ReadMenu @JvmOverloads constructor(
|
|
|
var cnaShowMenu: Boolean = false
|
|
|
private val callBack: CallBack get() = activity as CallBack
|
|
|
private val binding = ViewReadMenuBinding.inflate(LayoutInflater.from(context), this, true)
|
|
|
+ private var confirmSkipToChapter: Boolean = false
|
|
|
private val menuTopIn: Animation by lazy {
|
|
|
loadAnimation(context, R.anim.anim_readbook_top_in)
|
|
|
}
|
|
|
@@ -370,7 +371,27 @@ class ReadMenu @JvmOverloads constructor(
|
|
|
seekReadPage.setOnSeekBarChangeListener(object : SeekBarChangeListener {
|
|
|
|
|
|
override fun onStopTrackingTouch(seekBar: SeekBar) {
|
|
|
- ReadBook.skipToPage(seekBar.progress)
|
|
|
+ when (AppConfig.progressBarBehavior) {
|
|
|
+ "page" -> ReadBook.skipToPage(seekBar.progress)
|
|
|
+ "chapter" -> {
|
|
|
+ if (confirmSkipToChapter) {
|
|
|
+ callBack.skipToChapter(seekBar.progress)
|
|
|
+ } else {
|
|
|
+ context.alert("章节跳转确认", "确定要跳转章节吗?") {
|
|
|
+ yesButton {
|
|
|
+ confirmSkipToChapter = true
|
|
|
+ callBack.skipToChapter(seekBar.progress)
|
|
|
+ }
|
|
|
+ noButton {
|
|
|
+ upSeekBar()
|
|
|
+ }
|
|
|
+ onCancelled {
|
|
|
+ upSeekBar()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
})
|
|
|
@@ -453,8 +474,7 @@ class ReadMenu @JvmOverloads constructor(
|
|
|
} else {
|
|
|
binding.tvChapterUrl.gone()
|
|
|
}
|
|
|
- binding.seekReadPage.max = it.pageSize.minus(1)
|
|
|
- binding.seekReadPage.progress = ReadBook.durPageIndex
|
|
|
+ upSeekBar()
|
|
|
binding.tvPre.isEnabled = ReadBook.durChapterIndex != 0
|
|
|
binding.tvNext.isEnabled = ReadBook.durChapterIndex != ReadBook.chapterSize - 1
|
|
|
} ?: let {
|
|
|
@@ -463,6 +483,23 @@ class ReadMenu @JvmOverloads constructor(
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ fun upSeekBar() {
|
|
|
+ binding.seekReadPage.apply {
|
|
|
+ when (AppConfig.progressBarBehavior) {
|
|
|
+ "page" -> {
|
|
|
+ ReadBook.curTextChapter?.let {
|
|
|
+ max = it.pageSize.minus(1)
|
|
|
+ progress = ReadBook.durPageIndex
|
|
|
+ }
|
|
|
+ }
|
|
|
+ "chapter" -> {
|
|
|
+ max = ReadBook.chapterSize - 1
|
|
|
+ progress = ReadBook.durChapterIndex
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
fun setSeekPage(seek: Int) {
|
|
|
binding.seekReadPage.progress = seek
|
|
|
}
|
|
|
@@ -493,6 +530,7 @@ class ReadMenu @JvmOverloads constructor(
|
|
|
fun showLogin()
|
|
|
fun payAction()
|
|
|
fun disableSource()
|
|
|
+ fun skipToChapter(index: Int)
|
|
|
}
|
|
|
|
|
|
}
|