From 27ec907611bf3d812d2a770c90bbefc32a76f079 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Mon, 29 Jul 2019 23:48:23 +0200 Subject: [PATCH] fix NPE in Automation --- .../general/automation/dialogs/ChooseTriggerDialog.kt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/dialogs/ChooseTriggerDialog.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/dialogs/ChooseTriggerDialog.kt index cfd46b107a..b77c0f4a40 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/dialogs/ChooseTriggerDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/dialogs/ChooseTriggerDialog.kt @@ -19,7 +19,7 @@ class ChooseTriggerDialog : DialogFragment() { private var clickListener: OnClickListener? = null interface OnClickListener { - fun onClick(newTriggerObject: Trigger?) + fun onClick(newTriggerObject: Trigger) } override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, @@ -49,7 +49,9 @@ class ChooseTriggerDialog : DialogFragment() { // OK button ok.setOnClickListener { dismiss() - clickListener?.onClick(instantiateTrigger()) + instantiateTrigger()?.let { + clickListener?.onClick(it) + } } // Cancel button