This commit is contained in:
Milos Kozak 2022-04-04 12:11:43 +02:00
parent 8b6bd17df5
commit bfbc7ffd4b

View file

@ -19,6 +19,7 @@ import info.nightscout.androidaps.utils.DateUtil
import info.nightscout.androidaps.extensions.toVisibility import info.nightscout.androidaps.extensions.toVisibility
import info.nightscout.shared.sharedPreferences.SP import info.nightscout.shared.sharedPreferences.SP
import java.util.* import java.util.*
import java.util.concurrent.atomic.AtomicBoolean
import javax.inject.Inject import javax.inject.Inject
abstract class DialogFragmentWithDate : DaggerDialogFragment() { abstract class DialogFragmentWithDate : DaggerDialogFragment() {
@ -41,7 +42,7 @@ abstract class DialogFragmentWithDate : DaggerDialogFragment() {
private var mOnValueChangedListener: OnValueChangedListener? = null private var mOnValueChangedListener: OnValueChangedListener? = null
//one shot guards //one shot guards
private var okClicked: Boolean = false private var okClicked: AtomicBoolean = AtomicBoolean(false)
companion object { companion object {
@ -147,16 +148,16 @@ abstract class DialogFragmentWithDate : DaggerDialogFragment() {
(view.findViewById(R.id.ok) as Button?)?.setOnClickListener { (view.findViewById(R.id.ok) as Button?)?.setOnClickListener {
synchronized(okClicked) { synchronized(okClicked) {
if (okClicked) { if (okClicked.get()) {
aapsLogger.warn(LTag.UI, "guarding: ok already clicked for dialog: ${this.javaClass.name}") aapsLogger.warn(LTag.UI, "guarding: ok already clicked for dialog: ${this.javaClass.name}")
} else { } else {
okClicked = true okClicked.set(true)
if (submit()) { if (submit()) {
aapsLogger.debug(LTag.APS, "Submit pressed for Dialog: ${this.javaClass.name}") aapsLogger.debug(LTag.APS, "Submit pressed for Dialog: ${this.javaClass.name}")
dismiss() dismiss()
} else { } else {
aapsLogger.debug(LTag.APS, "Submit returned false for Dialog: ${this.javaClass.name}") aapsLogger.debug(LTag.APS, "Submit returned false for Dialog: ${this.javaClass.name}")
okClicked = false okClicked.set(false)
} }
} }
} }