diff --git a/app/src/main/java/io/legado/app/ui/book/info/BookInfoActivity.kt b/app/src/main/java/io/legado/app/ui/book/info/BookInfoActivity.kt index de21ed9b5..51d23caaa 100644 --- a/app/src/main/java/io/legado/app/ui/book/info/BookInfoActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/info/BookInfoActivity.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() diff --git a/app/src/main/java/io/legado/app/ui/book/info/BookInfoViewModel.kt b/app/src/main/java/io/legado/app/ui/book/info/BookInfoViewModel.kt index f6fb03b3b..0db62f64a 100644 --- a/app/src/main/java/io/legado/app/ui/book/info/BookInfoViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/book/info/BookInfoViewModel.kt @@ -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)