feat: 优化代码

pull/115/head
kunfei 5 years ago
parent 2c314a0745
commit de369e3b72
  1. 6
      app/src/main/java/io/legado/app/service/help/ReadBook.kt
  2. 6
      app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt
  3. 13
      app/src/main/java/io/legado/app/ui/book/read/page/PageView.kt

@ -127,6 +127,12 @@ object ReadBook {
saveRead()
}
fun setPageIndex(pageIndex: Int) {
durPageIndex = pageIndex
saveRead()
curPageChanged()
}
fun curPageChanged() {
callBack?.upPageProgress()
if (BaseReadAloudService.isRun) {

@ -505,12 +505,6 @@ class ReadBookActivity : VMBaseActivity<ReadBookViewModel>(R.layout.activity_boo
viewModel.changeTo(book)
}
override fun setPageIndex(pageIndex: Int) {
ReadBook.durPageIndex = pageIndex
ReadBook.saveRead()
ReadBook.curPageChanged()
}
override fun clickCenter() {
if (BaseReadAloudService.isRun) {
showReadAloudDialog()

@ -168,7 +168,7 @@ class PageView(context: Context, attrs: AttributeSet) :
get() = ReadBook.durChapterPos()
override fun setPageIndex(pageIndex: Int) {
callBack.setPageIndex(pageIndex)
ReadBook.setPageIndex(pageIndex)
}
override fun getChapterPosition(): Int {
@ -196,19 +196,8 @@ class PageView(context: Context, attrs: AttributeSet) :
}
interface CallBack {
val isInitFinish: Boolean
/**
* 保存页数
*/
fun setPageIndex(pageIndex: Int)
/**
* 点击屏幕中间
*/
fun clickCenter()
fun screenOffTimerStart()
}
}

Loading…
Cancel
Save