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 840b2f54e..4963fe860 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 @@ -21,6 +21,10 @@ class BookInfoEditActivity : VMBaseActivity(), ChangeCoverDialog.CallBack { + private val selectCover = registerForActivityResult(ActivityResultContracts.GetContent()) { + coverChangeTo(it) + } + override val viewModel: BookInfoEditViewModel by viewModels() @@ -57,7 +61,7 @@ class BookInfoEditActivity : } } tvSelectCover.setOnClickListener { - selectImage() + selectCover.launch("image/*") } tvRefreshCover.setOnClickListener { viewModel.book?.customCoverUrl = tieCoverUrl.text?.toString() @@ -93,12 +97,6 @@ class BookInfoEditActivity : } } - private fun selectImage() { - registerForActivityResult(ActivityResultContracts.GetContent()) { - coverChangeTo(it) - }.launch("image/*") - } - override fun coverChangeTo(coverUrl: String) { viewModel.book?.customCoverUrl = coverUrl binding.tieCoverUrl.setText(coverUrl)