pull/1013/head
gedoor 4 years ago
parent abd30ef58f
commit fa7f69c5ef
  1. 2
      app/src/main/java/io/legado/app/ui/book/info/BookInfoActivity.kt
  2. 10
      app/src/main/java/io/legado/app/ui/book/info/BookInfoViewModel.kt

@ -55,6 +55,7 @@ class BookInfoActivity :
viewModel.bookData.value?.let { book ->
launch {
withContext(IO) {
viewModel.durChapterIndex = it.first
book.durChapterIndex = it.first
book.durChapterPos = it.second
appDb.bookDao.update(book)
@ -75,6 +76,7 @@ class BookInfoActivity :
private val readBookResult = registerForActivityResult(
ActivityResultContracts.StartActivityForResult()
) {
viewModel.refreshData(intent)
if (it.resultCode == RESULT_OK) {
viewModel.inBookshelf = true
upTvBookshelf()

@ -35,6 +35,16 @@ class BookInfoViewModel(application: Application) : BaseViewModel(application) {
}
}
fun refreshData(intent: Intent) {
execute {
val name = intent.getStringExtra("name") ?: ""
val author = intent.getStringExtra("author") ?: ""
appDb.bookDao.getBook(name, author)?.let { book ->
setBook(book)
}
}
}
private fun setBook(book: Book) {
durChapterIndex = book.durChapterIndex
bookData.postValue(book)

Loading…
Cancel
Save