This commit is contained in:
kunfei
2022-03-20 11:08:42 +08:00
parent 3bcef6fe9d
commit d279347bd1
2 changed files with 78 additions and 43 deletions
@@ -8,6 +8,7 @@ import android.view.MenuItem
import androidx.activity.viewModels import androidx.activity.viewModels
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.constant.BookType
import io.legado.app.data.entities.Book import io.legado.app.data.entities.Book
import io.legado.app.databinding.ActivityBookInfoEditBinding import io.legado.app.databinding.ActivityBookInfoEditBinding
import io.legado.app.ui.book.changecover.ChangeCoverDialog import io.legado.app.ui.book.changecover.ChangeCoverDialog
@@ -70,6 +71,13 @@ class BookInfoEditActivity :
private fun upView(book: Book) = binding.run { private fun upView(book: Book) = binding.run {
tieBookName.setText(book.name) tieBookName.setText(book.name)
tieBookAuthor.setText(book.author) tieBookAuthor.setText(book.author)
spType.setSelection(
when (book.type) {
BookType.image -> 2
BookType.audio -> 1
else -> 0
}
)
tieCoverUrl.setText(book.getDisplayCover()) tieCoverUrl.setText(book.getDisplayCover())
tieBookIntro.setText(book.getDisplayIntro()) tieBookIntro.setText(book.getDisplayIntro())
upCover() upCover()
@@ -85,6 +93,11 @@ class BookInfoEditActivity :
viewModel.book?.let { book -> viewModel.book?.let { book ->
book.name = tieBookName.text?.toString() ?: "" book.name = tieBookName.text?.toString() ?: ""
book.author = tieBookAuthor.text?.toString() ?: "" book.author = tieBookAuthor.text?.toString() ?: ""
book.type = when (spType.selectedItemPosition) {
2 -> BookType.image
1 -> BookType.audio
else -> BookType.default
}
val customCoverUrl = tieCoverUrl.text?.toString() val customCoverUrl = tieCoverUrl.text?.toString()
book.customCoverUrl = if (customCoverUrl == book.coverUrl) null else customCoverUrl book.customCoverUrl = if (customCoverUrl == book.coverUrl) null else customCoverUrl
book.customIntro = tieBookIntro.text?.toString() book.customIntro = tieBookIntro.text?.toString()
@@ -12,16 +12,6 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
app:title="@string/book_info_edit" /> app:title="@string/book_info_edit" />
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
@@ -71,6 +61,38 @@
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_gravity="center_vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/book_type"
android:layout_marginLeft="12dp"
android:layout_marginRight="3dp"
tools:ignore="RtlHardcoded" />
<androidx.appcompat.widget.AppCompatSpinner
android:id="@+id/sp_type"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:entries="@array/book_type"
app:theme="@style/Spinner" />
</LinearLayout>
<io.legado.app.ui.widget.text.TextInputLayout <io.legado.app.ui.widget.text.TextInputLayout
android:id="@+id/til_cover_url" android:id="@+id/til_cover_url"
android:layout_width="match_parent" android:layout_width="match_parent"
@@ -132,6 +154,6 @@
</io.legado.app.ui.widget.text.TextInputLayout> </io.legado.app.ui.widget.text.TextInputLayout>
</LinearLayout> </LinearLayout>
</ScrollView> </androidx.core.widget.NestedScrollView>
</LinearLayout> </LinearLayout>