pull/32/head
kunfei 5 years ago
parent 720ced5291
commit 86b954ea94
  1. 1
      app/src/main/java/io/legado/app/ui/readbook/ReadBookActivity.kt
  2. 17
      app/src/main/java/io/legado/app/ui/readbook/ReadBookViewModel.kt

@ -328,6 +328,7 @@ class ReadBookActivity : VMBaseActivity<ReadBookViewModel>(R.layout.activity_rea
observeEvent<Int>(Bus.TTS_RANGE_START) {}
observeEvent<String>(Bus.TIME_CHANGED) { page_view.upTime() }
observeEvent<Int>(Bus.BATTERY_CHANGED) { page_view.upBattery(it) }
observeEvent<BookChapter>(Bus.OPEN_CHAPTER) { viewModel.openChapter(it) }
observeEventSticky<String>(Bus.READ_ALOUD) { onClickReadAloud() }
observeEventSticky<Int>(Bus.UP_CONFIG) {
when (it) {

@ -169,6 +169,23 @@ class ReadBookViewModel(application: Application) : BaseViewModel(application) {
}
fun openChapter(chapter: BookChapter) {
if (chapter.index != durChapterIndex) {
durChapterIndex = chapter.index
durPageIndex = 0
}
callBack?.bookLoadFinish()
}
fun saveRead() {
execute {
bookData.value?.let { book ->
book.durChapterIndex = durChapterIndex
book.durChapterPos = durPageIndex
}
}
}
override fun onCleared() {
super.onCleared()
ReadAloudService.stop(context)

Loading…
Cancel
Save