pull/51/head
kunfei 5 years ago
parent 5792856a75
commit faf98af304
  1. 16
      app/src/main/java/io/legado/app/service/help/ReadBook.kt
  2. 4
      app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt
  3. 7
      app/src/main/java/io/legado/app/ui/book/read/ReadBookViewModel.kt

@ -11,7 +11,6 @@ import io.legado.app.help.IntentDataHelp
import io.legado.app.help.coroutine.Coroutine
import io.legado.app.model.WebBook
import io.legado.app.service.BaseReadAloudService
import io.legado.app.ui.book.read.ReadBookViewModel
import io.legado.app.ui.widget.page.ChapterProvider
import io.legado.app.ui.widget.page.TextChapter
import kotlinx.coroutines.*
@ -24,7 +23,7 @@ object ReadBook {
var book: Book? = null
var inBookshelf = false
var chapterSize = 0
var callBack: ReadBookViewModel.CallBack? = null
var callBack: CallBack? = null
var durChapterIndex = 0
var durPageIndex = 0
var isLocalBook = true
@ -77,7 +76,7 @@ object ReadBook {
}
}
saveRead()
callBack?.curChapterChanged()
callBack?.upView()
curPageChanged()
return true
} else {
@ -107,7 +106,7 @@ object ReadBook {
}
}
saveRead()
callBack?.curChapterChanged()
callBack?.upView()
curPageChanged()
return true
} else {
@ -226,7 +225,7 @@ object ReadBook {
durChapterIndex -> withContext(Main) {
curTextChapter = ChapterProvider.getTextChapter(chapter, c, chapterSize)
callBack?.upContent()
callBack?.curChapterChanged()
callBack?.upView()
curPageChanged()
callBack?.contentLoadFinish()
}
@ -258,4 +257,11 @@ object ReadBook {
}
}
interface CallBack {
fun loadContent()
fun upContent(position: Int = 0)
fun upView()
fun upPageProgress()
fun contentLoadFinish()
}
}

@ -55,7 +55,7 @@ class ReadBookActivity : VMBaseActivity<ReadBookViewModel>(R.layout.activity_boo
ReadMenu.CallBack,
ReadAloudDialog.CallBack,
ChangeSourceDialog.CallBack,
ReadBookViewModel.CallBack,
ReadBook.CallBack,
ColorPickerDialogListener {
override val viewModel: ReadBookViewModel
get() = getViewModel(ReadBookViewModel::class.java)
@ -274,7 +274,7 @@ class ReadBookActivity : VMBaseActivity<ReadBookViewModel>(R.layout.activity_boo
page_view.upContent(position)
}
override fun curChapterChanged() {
override fun upView() {
ReadBook.curTextChapter?.let {
tv_chapter_name.text = it.title
tv_chapter_name.visible()

@ -200,11 +200,4 @@ class ReadBookViewModel(application: Application) : BaseViewModel(application) {
}
}
interface CallBack {
fun loadContent()
fun upContent(position: Int = 0)
fun curChapterChanged()
fun upPageProgress()
fun contentLoadFinish()
}
}
Loading…
Cancel
Save