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

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