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 0e887fad4..09f1e0254 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 @@ -352,7 +352,7 @@ class BookInfoActivity : super.onActivityResult(requestCode, resultCode, data) when (requestCode) { requestCodeSourceEdit -> if (resultCode == Activity.RESULT_OK) { - viewModel.initData(intent) + viewModel.upEditBook() } requestCodeChapterList -> if (resultCode == Activity.RESULT_OK) { viewModel.bookData.value?.let { 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 3820f3655..800024cf5 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 @@ -226,4 +226,12 @@ class BookInfoViewModel(application: Application) : BaseViewModel(application) { success?.invoke() } } + + fun upEditBook() { + bookData.value?.let { + App.db.bookDao().getBook(it.bookUrl)?.let { book -> + bookData.postValue(book) + } + } + } } \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/ui/book/info/edit/BookInfoEditViewModel.kt b/app/src/main/java/io/legado/app/ui/book/info/edit/BookInfoEditViewModel.kt index 66602c1d7..a0604035e 100644 --- a/app/src/main/java/io/legado/app/ui/book/info/edit/BookInfoEditViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/book/info/edit/BookInfoEditViewModel.kt @@ -5,6 +5,7 @@ import androidx.lifecycle.MutableLiveData import io.legado.app.App import io.legado.app.base.BaseViewModel import io.legado.app.data.entities.Book +import io.legado.app.service.help.ReadBook class BookInfoEditViewModel(application: Application) : BaseViewModel(application) { var book: Book? = null @@ -21,6 +22,9 @@ class BookInfoEditViewModel(application: Application) : BaseViewModel(applicatio fun saveBook(book: Book, success: (() -> Unit)?) { execute { + if (ReadBook.book?.bookUrl == book.bookUrl) { + ReadBook.book = book + } App.db.bookDao().insert(book) }.onSuccess { success?.invoke()