From d0381ed78666e28995320ecabb3bf4b694c747d3 Mon Sep 17 00:00:00 2001 From: kunfei Date: Sun, 11 Aug 2019 17:12:42 +0800 Subject: [PATCH] up --- .../legado/app/ui/bookinfo/BookInfoEditActivity.kt | 12 +++++++----- ...BookInfoViewModel.kt => BookInfoEditViewModel.kt} | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) rename app/src/main/java/io/legado/app/ui/bookinfo/{BookInfoViewModel.kt => BookInfoEditViewModel.kt} (89%) 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()