diff --git a/app/src/main/java/io/legado/app/ui/bookinfo/BookInfoEditActivity.kt b/app/src/main/java/io/legado/app/ui/bookinfo/BookInfoEditActivity.kt index 61387502d..fc15bd18b 100644 --- a/app/src/main/java/io/legado/app/ui/bookinfo/BookInfoEditActivity.kt +++ b/app/src/main/java/io/legado/app/ui/bookinfo/BookInfoEditActivity.kt @@ -11,14 +11,16 @@ import io.legado.app.utils.getViewModel import io.legado.app.utils.toast import kotlinx.android.synthetic.main.activity_book_info_edit.* -class BookInfoEditActivity : VMBaseActivity(R.layout.activity_book_info_edit) { - override val viewModel: BookInfoViewModel - get() = getViewModel(BookInfoViewModel::class.java) +class BookInfoEditActivity : VMBaseActivity(R.layout.activity_book_info_edit) { + override val viewModel: BookInfoEditViewModel + get() = getViewModel(BookInfoEditViewModel::class.java) override fun onActivityCreated(savedInstanceState: Bundle?) { viewModel.bookData.observe(this, Observer { upView(it) }) - intent.getStringExtra("bookUrl")?.let { - viewModel.loadBook(it) + if (viewModel.bookData.value == null) { + intent.getStringExtra("bookUrl")?.let { + viewModel.loadBook(it) + } } } diff --git a/app/src/main/java/io/legado/app/ui/bookinfo/BookInfoViewModel.kt b/app/src/main/java/io/legado/app/ui/bookinfo/BookInfoEditViewModel.kt similarity index 89% rename from app/src/main/java/io/legado/app/ui/bookinfo/BookInfoViewModel.kt rename to app/src/main/java/io/legado/app/ui/bookinfo/BookInfoEditViewModel.kt index 8b4c0cb71..b331b8a78 100644 --- a/app/src/main/java/io/legado/app/ui/bookinfo/BookInfoViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/bookinfo/BookInfoEditViewModel.kt @@ -6,7 +6,7 @@ import io.legado.app.App import io.legado.app.base.BaseViewModel import io.legado.app.data.entities.Book -class BookInfoViewModel(application: Application) : BaseViewModel(application) { +class BookInfoEditViewModel(application: Application) : BaseViewModel(application) { val bookData = MutableLiveData()