From 3f018fc2ed1db8ee07784e9b39d84e49ccc0006a Mon Sep 17 00:00:00 2001 From: kunfei Date: Sun, 11 Aug 2019 00:12:32 +0800 Subject: [PATCH] up --- .../app/ui/bookinfo/BookInfoEditActivity.kt | 14 +++++++- .../app/ui/bookinfo/BookInfoViewModel.kt | 4 +++ .../res/layout/activity_book_info_edit.xml | 34 +++++++++---------- 3 files changed, 34 insertions(+), 18 deletions(-) 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 33fd29e83..5e632cd6c 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 @@ -3,16 +3,19 @@ package io.legado.app.ui.bookinfo import android.os.Bundle import android.view.Menu import android.view.MenuItem +import androidx.lifecycle.Observer import io.legado.app.R import io.legado.app.base.VMBaseActivity +import io.legado.app.data.entities.Book import io.legado.app.utils.getViewModel +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) override fun onActivityCreated(savedInstanceState: Bundle?) { - + viewModel.bookData.observe(this, Observer { upView(it) }) } override fun onCompatCreateOptionsMenu(menu: Menu): Boolean { @@ -27,4 +30,13 @@ class BookInfoEditActivity : VMBaseActivity(R.layout.activity } return super.onCompatOptionsItemSelected(item) } + + private fun upView(book: Book) { + tie_book_name.setText(book.name) + tie_book_author.setText(book.author) + tie_cover_url.setText(book.getDisplayCover()) + tie_book_intro.setText(book.getDisplayIntro()) + } + + } \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/ui/bookinfo/BookInfoViewModel.kt b/app/src/main/java/io/legado/app/ui/bookinfo/BookInfoViewModel.kt index cf943895d..d47df4b70 100644 --- a/app/src/main/java/io/legado/app/ui/bookinfo/BookInfoViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/bookinfo/BookInfoViewModel.kt @@ -1,8 +1,12 @@ package io.legado.app.ui.bookinfo import android.app.Application +import androidx.lifecycle.MutableLiveData import io.legado.app.base.BaseViewModel +import io.legado.app.data.entities.Book class BookInfoViewModel(application: Application) : BaseViewModel(application) { + val bookData = MutableLiveData() + } \ No newline at end of file diff --git a/app/src/main/res/layout/activity_book_info_edit.xml b/app/src/main/res/layout/activity_book_info_edit.xml index b56e9d55a..4244c2b89 100644 --- a/app/src/main/res/layout/activity_book_info_edit.xml +++ b/app/src/main/res/layout/activity_book_info_edit.xml @@ -28,7 +28,7 @@ android:orientation="horizontal" android:padding="5dp"> - - - - + - - - + - - - + - - - - - - +