pull/32/head
kunfei 5 years ago
parent 3c78f855f6
commit 3f018fc2ed
  1. 14
      app/src/main/java/io/legado/app/ui/bookinfo/BookInfoEditActivity.kt
  2. 4
      app/src/main/java/io/legado/app/ui/bookinfo/BookInfoViewModel.kt
  3. 34
      app/src/main/res/layout/activity_book_info_edit.xml

@ -3,16 +3,19 @@ package io.legado.app.ui.bookinfo
import android.os.Bundle import android.os.Bundle
import android.view.Menu import android.view.Menu
import android.view.MenuItem import android.view.MenuItem
import androidx.lifecycle.Observer
import io.legado.app.R import io.legado.app.R
import io.legado.app.base.VMBaseActivity import io.legado.app.base.VMBaseActivity
import io.legado.app.data.entities.Book
import io.legado.app.utils.getViewModel import io.legado.app.utils.getViewModel
import kotlinx.android.synthetic.main.activity_book_info_edit.*
class BookInfoEditActivity : VMBaseActivity<BookInfoViewModel>(R.layout.activity_book_info_edit) { class BookInfoEditActivity : VMBaseActivity<BookInfoViewModel>(R.layout.activity_book_info_edit) {
override val viewModel: BookInfoViewModel override val viewModel: BookInfoViewModel
get() = getViewModel(BookInfoViewModel::class.java) get() = getViewModel(BookInfoViewModel::class.java)
override fun onActivityCreated(savedInstanceState: Bundle?) { override fun onActivityCreated(savedInstanceState: Bundle?) {
viewModel.bookData.observe(this, Observer { upView(it) })
} }
override fun onCompatCreateOptionsMenu(menu: Menu): Boolean { override fun onCompatCreateOptionsMenu(menu: Menu): Boolean {
@ -27,4 +30,13 @@ class BookInfoEditActivity : VMBaseActivity<BookInfoViewModel>(R.layout.activity
} }
return super.onCompatOptionsItemSelected(item) 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())
}
} }

@ -1,8 +1,12 @@
package io.legado.app.ui.bookinfo package io.legado.app.ui.bookinfo
import android.app.Application import android.app.Application
import androidx.lifecycle.MutableLiveData
import io.legado.app.base.BaseViewModel import io.legado.app.base.BaseViewModel
import io.legado.app.data.entities.Book
class BookInfoViewModel(application: Application) : BaseViewModel(application) { class BookInfoViewModel(application: Application) : BaseViewModel(application) {
val bookData = MutableLiveData<Book>()
} }

@ -28,7 +28,7 @@
android:orientation="horizontal" android:orientation="horizontal"
android:padding="5dp"> android:padding="5dp">
<com.kunfei.bookshelf.widget.CoverImageView <io.legado.app.ui.widget.image.CoverImageView
android:id="@+id/iv_cover" android:id="@+id/iv_cover"
android:layout_width="90dp" android:layout_width="90dp"
android:layout_height="126dp" android:layout_height="126dp"
@ -42,47 +42,47 @@
android:orientation="vertical" android:orientation="vertical"
android:padding="5dp"> android:padding="5dp">
<com.kunfei.bookshelf.widget.views.ATETextInputLayout <io.legado.app.lib.theme.view.ATETextInputLayout
android:id="@+id/til_book_name" android:id="@+id/til_book_name"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:hint="@string/book_name"> android:hint="@string/book_name">
<com.kunfei.bookshelf.widget.views.ATEEditText <io.legado.app.lib.theme.view.ATEEditText
android:id="@+id/tie_book_name" android:id="@+id/tie_book_name"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:singleLine="true" /> android:singleLine="true" />
</com.kunfei.bookshelf.widget.views.ATETextInputLayout> </io.legado.app.lib.theme.view.ATETextInputLayout>
<com.kunfei.bookshelf.widget.views.ATETextInputLayout <io.legado.app.lib.theme.view.ATETextInputLayout
android:id="@+id/til_book_author" android:id="@+id/til_book_author"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:hint="@string/author"> android:hint="@string/author">
<com.kunfei.bookshelf.widget.views.ATEEditText <io.legado.app.lib.theme.view.ATEEditText
android:id="@+id/tie_book_author" android:id="@+id/tie_book_author"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:singleLine="true" /> android:singleLine="true" />
</com.kunfei.bookshelf.widget.views.ATETextInputLayout> </io.legado.app.lib.theme.view.ATETextInputLayout>
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>
<com.kunfei.bookshelf.widget.views.ATETextInputLayout <io.legado.app.lib.theme.view.ATETextInputLayout
android:id="@+id/til_cover_url" android:id="@+id/til_cover_url"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="5dp" android:layout_marginTop="5dp"
android:hint="@string/cover_path"> android:hint="@string/cover_path">
<com.kunfei.bookshelf.widget.views.ATEEditText <io.legado.app.lib.theme.view.ATEEditText
android:id="@+id/tie_cover_url" android:id="@+id/tie_cover_url"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" /> android:layout_height="wrap_content" />
</com.kunfei.bookshelf.widget.views.ATETextInputLayout> </io.legado.app.lib.theme.view.ATETextInputLayout>
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
@ -91,14 +91,14 @@
android:paddingStart="5dp" android:paddingStart="5dp"
android:paddingEnd="5dp"> android:paddingEnd="5dp">
<com.kunfei.bookshelf.widget.views.ATEStrokeTextView <io.legado.app.lib.theme.view.ATEStrokeTextView
android:id="@+id/tv_select_cover" android:id="@+id/tv_select_cover"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:padding="5dp" android:padding="5dp"
android:text="选择本地图片" /> android:text="选择本地图片" />
<com.kunfei.bookshelf.widget.views.ATEStrokeTextView <io.legado.app.lib.theme.view.ATEStrokeTextView
android:id="@+id/tv_change_cover" android:id="@+id/tv_change_cover"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
@ -107,7 +107,7 @@
android:text="封面换源" android:text="封面换源"
tools:ignore="RtlHardcoded" /> tools:ignore="RtlHardcoded" />
<com.kunfei.bookshelf.widget.views.ATEStrokeTextView <io.legado.app.lib.theme.view.ATEStrokeTextView
android:id="@+id/tv_refresh_cover" android:id="@+id/tv_refresh_cover"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
@ -118,18 +118,18 @@
</LinearLayout> </LinearLayout>
<com.kunfei.bookshelf.widget.views.ATETextInputLayout <io.legado.app.lib.theme.view.ATETextInputLayout
android:id="@+id/til_book_jj" android:id="@+id/til_book_jj"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="10dp" android:layout_marginTop="10dp"
android:hint="@string/book_intro"> android:hint="@string/book_intro">
<com.kunfei.bookshelf.widget.views.ATEEditText <io.legado.app.lib.theme.view.ATEEditText
android:id="@+id/tie_book_jj" android:id="@+id/tie_book_intro"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" /> android:layout_height="wrap_content" />
</com.kunfei.bookshelf.widget.views.ATETextInputLayout> </io.legado.app.lib.theme.view.ATETextInputLayout>
</LinearLayout> </LinearLayout>
</ScrollView> </ScrollView>

Loading…
Cancel
Save