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.help.coroutine.Coroutine
import io.legado.app.model.WebBook import io.legado.app.model.WebBook
import io.legado.app.service.BaseReadAloudService 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.ChapterProvider
import io.legado.app.ui.widget.page.TextChapter import io.legado.app.ui.widget.page.TextChapter
import kotlinx.coroutines.* import kotlinx.coroutines.*
@ -24,7 +23,7 @@ object ReadBook {
var book: Book? = null var book: Book? = null
var inBookshelf = false var inBookshelf = false
var chapterSize = 0 var chapterSize = 0
var callBack: ReadBookViewModel.CallBack? = null var callBack: CallBack? = null
var durChapterIndex = 0 var durChapterIndex = 0
var durPageIndex = 0 var durPageIndex = 0
var isLocalBook = true var isLocalBook = true
@ -77,7 +76,7 @@ object ReadBook {
} }
} }
saveRead() saveRead()
callBack?.curChapterChanged() callBack?.upView()
curPageChanged() curPageChanged()
return true return true
} else { } else {
@ -107,7 +106,7 @@ object ReadBook {
} }
} }
saveRead() saveRead()
callBack?.curChapterChanged() callBack?.upView()
curPageChanged() curPageChanged()
return true return true
} else { } else {
@ -226,7 +225,7 @@ object ReadBook {
durChapterIndex -> withContext(Main) { durChapterIndex -> withContext(Main) {
curTextChapter = ChapterProvider.getTextChapter(chapter, c, chapterSize) curTextChapter = ChapterProvider.getTextChapter(chapter, c, chapterSize)
callBack?.upContent() callBack?.upContent()
callBack?.curChapterChanged() callBack?.upView()
curPageChanged() curPageChanged()
callBack?.contentLoadFinish() 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, ReadMenu.CallBack,
ReadAloudDialog.CallBack, ReadAloudDialog.CallBack,
ChangeSourceDialog.CallBack, ChangeSourceDialog.CallBack,
ReadBookViewModel.CallBack, ReadBook.CallBack,
ColorPickerDialogListener { ColorPickerDialogListener {
override val viewModel: ReadBookViewModel override val viewModel: ReadBookViewModel
get() = getViewModel(ReadBookViewModel::class.java) get() = getViewModel(ReadBookViewModel::class.java)
@ -274,7 +274,7 @@ class ReadBookActivity : VMBaseActivity<ReadBookViewModel>(R.layout.activity_boo
page_view.upContent(position) page_view.upContent(position)
} }
override fun curChapterChanged() { override fun upView() {
ReadBook.curTextChapter?.let { ReadBook.curTextChapter?.let {
tv_chapter_name.text = it.title tv_chapter_name.text = it.title
tv_chapter_name.visible() 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