pull/32/head
kunfei 5 years ago
parent 4be2f8d2b1
commit 8679723300
  1. 5
      app/src/main/java/io/legado/app/ui/readbook/ReadBookActivity.kt
  2. 7
      app/src/main/java/io/legado/app/ui/readbook/ReadBookViewModel.kt

@ -190,6 +190,7 @@ class ReadBookActivity : VMBaseActivity<ReadBookViewModel>(R.layout.activity_rea
override fun onCompatOptionsItemSelected(item: MenuItem): Boolean {
when (item.itemId) {
R.id.menu_change_source -> {
read_menu.runMenuOut()
if (changeSourceDialog == null) {
viewModel.bookData.value?.let {
changeSourceDialog = ChangeSourceDialog
@ -287,6 +288,10 @@ class ReadBookActivity : VMBaseActivity<ReadBookViewModel>(R.layout.activity_rea
}
}
override fun upContent() {
page_view.upContent()
}
private fun curChapterChanged() {
viewModel.curTextChapter?.let {
tv_chapter_name.text = it.title

@ -42,7 +42,6 @@ class ReadBookViewModel(application: Application) : BaseViewModel(application) {
} else {
App.db.bookDao().lastReadBook
}
saveRead(book)
book?.let {
durChapterIndex = book.durChapterIndex
durPageIndex = book.durChapterPos
@ -66,6 +65,7 @@ class ReadBookViewModel(application: Application) : BaseViewModel(application) {
chapterListFinish.postValue(true)
}
}
saveRead(book)
}.onError { it.printStackTrace() }
}
@ -225,6 +225,10 @@ class ReadBookViewModel(application: Application) : BaseViewModel(application) {
bookData.value?.let {
App.db.bookDao().delete(it.bookUrl)
}
prevTextChapter = null
curTextChapter = null
nextTextChapter = null
callBack?.upContent()
App.db.bookDao().insert(book)
bookData.postValue(book)
App.db.bookSourceDao().getBookSource(book.origin)?.let {
@ -321,5 +325,6 @@ class ReadBookViewModel(application: Application) : BaseViewModel(application) {
interface CallBack {
fun contentLoadFinish(bookChapter: BookChapter, content: String)
fun upContent()
}
}
Loading…
Cancel
Save