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"> - - - - + - - - + - - - + - - - - - - +