From 235558ea4eb15efbb717a232e7b0f3011a8a58de Mon Sep 17 00:00:00 2001 From: gedoor Date: Fri, 4 Dec 2020 10:49:21 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ui/book/info/edit/BookInfoEditActivity.kt | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/book/info/edit/BookInfoEditActivity.kt b/app/src/main/java/io/legado/app/ui/book/info/edit/BookInfoEditActivity.kt index 0c9dc3d81..f5e4e9f38 100644 --- a/app/src/main/java/io/legado/app/ui/book/info/edit/BookInfoEditActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/info/edit/BookInfoEditActivity.kt @@ -54,26 +54,26 @@ class BookInfoEditActivity : return super.onCompatOptionsItemSelected(item) } - private fun initEvent() { - binding.tvChangeCover.onClick { + private fun initEvent() = with(binding) { + tvChangeCover.onClick { viewModel.bookData.value?.let { ChangeCoverDialog.show(supportFragmentManager, it.name, it.author) } } - binding.tvSelectCover.onClick { + tvSelectCover.onClick { selectImage() } - binding.tvRefreshCover.onClick { - viewModel.book?.customCoverUrl = binding.tieCoverUrl.text?.toString() + tvRefreshCover.onClick { + viewModel.book?.customCoverUrl = tieCoverUrl.text?.toString() upCover() } } - private fun upView(book: Book) { - binding.tieBookName.setText(book.name) - binding.tieBookAuthor.setText(book.author) - binding.tieCoverUrl.setText(book.getDisplayCover()) - binding.tieBookIntro.setText(book.getDisplayIntro()) + private fun upView(book: Book) = with(binding) { + tieBookName.setText(book.name) + tieBookAuthor.setText(book.author) + tieCoverUrl.setText(book.getDisplayCover()) + tieBookIntro.setText(book.getDisplayIntro()) upCover() } @@ -83,13 +83,13 @@ class BookInfoEditActivity : } } - private fun saveData() { + private fun saveData() = with(binding) { viewModel.book?.let { book -> - book.name = binding.tieBookName.text?.toString() ?: "" - book.author = binding.tieBookAuthor.text?.toString() ?: "" - val customCoverUrl = binding.tieCoverUrl.text?.toString() + book.name = tieBookName.text?.toString() ?: "" + book.author = tieBookAuthor.text?.toString() ?: "" + val customCoverUrl = tieCoverUrl.text?.toString() book.customCoverUrl = if (customCoverUrl == book.coverUrl) null else customCoverUrl - book.customIntro = binding.tieBookIntro.text?.toString() + book.customIntro = tieBookIntro.text?.toString() viewModel.saveBook(book) { setResult(Activity.RESULT_OK) finish()