From bfbc7ffd4b2fb03b813424c45fd840e6f7a8e985 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Mon, 4 Apr 2022 12:11:43 +0200 Subject: [PATCH] lint --- .../androidaps/dialogs/DialogFragmentWithDate.kt | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/core/src/main/java/info/nightscout/androidaps/dialogs/DialogFragmentWithDate.kt b/core/src/main/java/info/nightscout/androidaps/dialogs/DialogFragmentWithDate.kt index dbc27f2124..95fb06ff08 100644 --- a/core/src/main/java/info/nightscout/androidaps/dialogs/DialogFragmentWithDate.kt +++ b/core/src/main/java/info/nightscout/androidaps/dialogs/DialogFragmentWithDate.kt @@ -19,6 +19,7 @@ import info.nightscout.androidaps.utils.DateUtil import info.nightscout.androidaps.extensions.toVisibility import info.nightscout.shared.sharedPreferences.SP import java.util.* +import java.util.concurrent.atomic.AtomicBoolean import javax.inject.Inject abstract class DialogFragmentWithDate : DaggerDialogFragment() { @@ -41,7 +42,7 @@ abstract class DialogFragmentWithDate : DaggerDialogFragment() { private var mOnValueChangedListener: OnValueChangedListener? = null //one shot guards - private var okClicked: Boolean = false + private var okClicked: AtomicBoolean = AtomicBoolean(false) companion object { @@ -147,16 +148,16 @@ abstract class DialogFragmentWithDate : DaggerDialogFragment() { (view.findViewById(R.id.ok) as Button?)?.setOnClickListener { synchronized(okClicked) { - if (okClicked) { + if (okClicked.get()) { aapsLogger.warn(LTag.UI, "guarding: ok already clicked for dialog: ${this.javaClass.name}") } else { - okClicked = true + okClicked.set(true) if (submit()) { aapsLogger.debug(LTag.APS, "Submit pressed for Dialog: ${this.javaClass.name}") dismiss() } else { aapsLogger.debug(LTag.APS, "Submit returned false for Dialog: ${this.javaClass.name}") - okClicked = false + okClicked.set(false) } } }