pull/32/head
kunfei 5 years ago
parent cc51eaf123
commit d0381ed786
  1. 8
      app/src/main/java/io/legado/app/ui/bookinfo/BookInfoEditActivity.kt
  2. 2
      app/src/main/java/io/legado/app/ui/bookinfo/BookInfoEditViewModel.kt

@ -11,16 +11,18 @@ import io.legado.app.utils.getViewModel
import io.legado.app.utils.toast import io.legado.app.utils.toast
import kotlinx.android.synthetic.main.activity_book_info_edit.* import kotlinx.android.synthetic.main.activity_book_info_edit.*
class BookInfoEditActivity : VMBaseActivity<BookInfoViewModel>(R.layout.activity_book_info_edit) { class BookInfoEditActivity : VMBaseActivity<BookInfoEditViewModel>(R.layout.activity_book_info_edit) {
override val viewModel: BookInfoViewModel override val viewModel: BookInfoEditViewModel
get() = getViewModel(BookInfoViewModel::class.java) get() = getViewModel(BookInfoEditViewModel::class.java)
override fun onActivityCreated(savedInstanceState: Bundle?) { override fun onActivityCreated(savedInstanceState: Bundle?) {
viewModel.bookData.observe(this, Observer { upView(it) }) viewModel.bookData.observe(this, Observer { upView(it) })
if (viewModel.bookData.value == null) {
intent.getStringExtra("bookUrl")?.let { intent.getStringExtra("bookUrl")?.let {
viewModel.loadBook(it) viewModel.loadBook(it)
} }
} }
}
override fun onCompatCreateOptionsMenu(menu: Menu): Boolean { override fun onCompatCreateOptionsMenu(menu: Menu): Boolean {
menuInflater.inflate(R.menu.book_info_edit, menu) menuInflater.inflate(R.menu.book_info_edit, menu)

@ -6,7 +6,7 @@ import io.legado.app.App
import io.legado.app.base.BaseViewModel import io.legado.app.base.BaseViewModel
import io.legado.app.data.entities.Book import io.legado.app.data.entities.Book
class BookInfoViewModel(application: Application) : BaseViewModel(application) { class BookInfoEditViewModel(application: Application) : BaseViewModel(application) {
val bookData = MutableLiveData<Book>() val bookData = MutableLiveData<Book>()
Loading…
Cancel
Save