From e7fe6b0d83d61ba346f10f0ecdff8137ce6cd22f Mon Sep 17 00:00:00 2001 From: gedoor Date: Fri, 16 Apr 2021 22:19:13 +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/read/config/BgTextConfigDialog.kt | 8 +++----- .../ui/book/read/config/PaddingConfigDialog.kt | 16 ++++++---------- .../app/ui/book/read/config/ReadAloudDialog.kt | 12 +++++------- .../app/ui/book/read/config/ReadStyleDialog.kt | 10 ++++------ 4 files changed, 18 insertions(+), 28 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/book/read/config/BgTextConfigDialog.kt b/app/src/main/java/io/legado/app/ui/book/read/config/BgTextConfigDialog.kt index 51e288a13..1a89cd4b1 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/config/BgTextConfigDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/config/BgTextConfigDialog.kt @@ -148,11 +148,9 @@ class BgTextConfigDialog : BaseDialogFragment() { cancelButton() }.show() } - binding.swDarkStatusIcon.setOnCheckedChangeListener { buttonView, isChecked -> - if (buttonView?.isPressed == true) { - setCurStatusIconDark(isChecked) - (activity as? ReadBookActivity)?.upSystemUiVisibility() - } + binding.swDarkStatusIcon.setOnCheckedChangeListener { _, isChecked -> + setCurStatusIconDark(isChecked) + (activity as? ReadBookActivity)?.upSystemUiVisibility() } binding.tvTextColor.setOnClickListener { ColorPickerDialog.newBuilder() diff --git a/app/src/main/java/io/legado/app/ui/book/read/config/PaddingConfigDialog.kt b/app/src/main/java/io/legado/app/ui/book/read/config/PaddingConfigDialog.kt index fb6e340dc..938d0392e 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/config/PaddingConfigDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/config/PaddingConfigDialog.kt @@ -121,17 +121,13 @@ class PaddingConfigDialog : BaseDialogFragment() { footerPaddingRight = it postEvent(EventBus.UP_CONFIG, true) } - binding.cbShowTopLine.onCheckedChangeListener = { cb, isChecked -> - if (cb.isPressed) { - showHeaderLine = isChecked - postEvent(EventBus.UP_CONFIG, true) - } + binding.cbShowTopLine.onCheckedChangeListener = { _, isChecked -> + showHeaderLine = isChecked + postEvent(EventBus.UP_CONFIG, true) } - binding.cbShowBottomLine.onCheckedChangeListener = { cb, isChecked -> - if (cb.isPressed) { - showFooterLine = isChecked - postEvent(EventBus.UP_CONFIG, true) - } + binding.cbShowBottomLine.onCheckedChangeListener = { _, isChecked -> + showFooterLine = isChecked + postEvent(EventBus.UP_CONFIG, true) } } diff --git a/app/src/main/java/io/legado/app/ui/book/read/config/ReadAloudDialog.kt b/app/src/main/java/io/legado/app/ui/book/read/config/ReadAloudDialog.kt index 52f7e7d36..e134884b7 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/config/ReadAloudDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/config/ReadAloudDialog.kt @@ -81,8 +81,8 @@ class ReadAloudDialog : BaseDialogFragment() { tvSetting.setTextColor(textColor) cbTtsFollowSys.setTextColor(textColor) } - initOnChange() initData() + initOnChange() initEvent() } @@ -96,12 +96,10 @@ class ReadAloudDialog : BaseDialogFragment() { } private fun initOnChange() = with(binding) { - cbTtsFollowSys.setOnCheckedChangeListener { buttonView, isChecked -> - if (buttonView.isPressed) { - requireContext().putPrefBoolean("ttsFollowSys", isChecked) - seekTtsSpeechRate.isEnabled = !isChecked - upTtsSpeechRate() - } + cbTtsFollowSys.setOnCheckedChangeListener { _, isChecked -> + requireContext().putPrefBoolean("ttsFollowSys", isChecked) + seekTtsSpeechRate.isEnabled = !isChecked + upTtsSpeechRate() } seekTtsSpeechRate.setOnSeekBarChangeListener(object : SeekBarChangeListener { diff --git a/app/src/main/java/io/legado/app/ui/book/read/config/ReadStyleDialog.kt b/app/src/main/java/io/legado/app/ui/book/read/config/ReadStyleDialog.kt index 90f4a9b21..a6110a309 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/config/ReadStyleDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/config/ReadStyleDialog.kt @@ -136,12 +136,10 @@ class ReadStyleDialog : BaseDialogFragment(), FontSelectDialog.CallBack { ReadBookConfig.pageAnim = binding.rgPageAnim.getIndexById(checkedId) callBack?.upPageAnim() } - cbShareLayout.onCheckedChangeListener = { checkBox, isChecked -> - if (checkBox.isPressed) { - ReadBookConfig.shareLayout = isChecked - upView() - postEvent(EventBus.UP_CONFIG, true) - } + cbShareLayout.onCheckedChangeListener = { _, isChecked -> + ReadBookConfig.shareLayout = isChecked + upView() + postEvent(EventBus.UP_CONFIG, true) } dsbTextSize.onChanged = { ReadBookConfig.textSize = it + 5