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() saveRead()
} }
fun setPageIndex(pageIndex: Int) {
durPageIndex = pageIndex
saveRead()
curPageChanged()
}
fun curPageChanged() { fun curPageChanged() {
callBack?.upPageProgress() callBack?.upPageProgress()
if (BaseReadAloudService.isRun) { if (BaseReadAloudService.isRun) {

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

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

Loading…
Cancel
Save