From 67b06f51fea17afc95ef70506d6aa45b7a4737b6 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Tue, 16 Jul 2019 17:05:51 +0200 Subject: [PATCH] remove loop from actions --- .../general/automation/AutomationPlugin.java | 19 ++++++++++++++ .../dialogs/ChooseActionDialog.java | 25 ++----------------- 2 files changed, 21 insertions(+), 23 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/AutomationPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/AutomationPlugin.java index ffdce6a99c..dfaaad0177 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/AutomationPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/AutomationPlugin.java @@ -26,6 +26,14 @@ import info.nightscout.androidaps.interfaces.PluginDescription; import info.nightscout.androidaps.interfaces.PluginType; import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.general.automation.actions.Action; +import info.nightscout.androidaps.plugins.general.automation.actions.ActionLoopDisable; +import info.nightscout.androidaps.plugins.general.automation.actions.ActionLoopEnable; +import info.nightscout.androidaps.plugins.general.automation.actions.ActionLoopResume; +import info.nightscout.androidaps.plugins.general.automation.actions.ActionLoopSuspend; +import info.nightscout.androidaps.plugins.general.automation.actions.ActionNotification; +import info.nightscout.androidaps.plugins.general.automation.actions.ActionProfileSwitchPercent; +import info.nightscout.androidaps.plugins.general.automation.actions.ActionStartTempTarget; +import info.nightscout.androidaps.plugins.general.automation.actions.ActionStopTempTarget; import info.nightscout.androidaps.plugins.general.automation.events.EventAutomationDataChanged; import info.nightscout.androidaps.plugins.general.automation.events.EventAutomationUpdateGui; import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventAutosensCalculationFinished; @@ -214,4 +222,15 @@ public class AutomationPlugin extends PluginBase { } storeToSP(); // save last run time } + + public static final List actionDummyObjects = new ArrayList() {{ + //add(new ActionLoopDisable()); + //add(new ActionLoopEnable()); + //add(new ActionLoopResume()); + //add(new ActionLoopSuspend()); + add(new ActionStartTempTarget()); + add(new ActionStopTempTarget()); + add(new ActionNotification()); + add(new ActionProfileSwitchPercent()); + }}; } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/dialogs/ChooseActionDialog.java b/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/dialogs/ChooseActionDialog.java index b9b12edb52..ef83b1b661 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/dialogs/ChooseActionDialog.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/dialogs/ChooseActionDialog.java @@ -10,23 +10,13 @@ import android.widget.RadioGroup; import androidx.annotation.NonNull; import androidx.fragment.app.DialogFragment; -import java.util.ArrayList; -import java.util.List; - import butterknife.BindView; import butterknife.ButterKnife; import butterknife.OnClick; import butterknife.Unbinder; import info.nightscout.androidaps.R; +import info.nightscout.androidaps.plugins.general.automation.AutomationPlugin; import info.nightscout.androidaps.plugins.general.automation.actions.Action; -import info.nightscout.androidaps.plugins.general.automation.actions.ActionLoopDisable; -import info.nightscout.androidaps.plugins.general.automation.actions.ActionLoopEnable; -import info.nightscout.androidaps.plugins.general.automation.actions.ActionLoopResume; -import info.nightscout.androidaps.plugins.general.automation.actions.ActionLoopSuspend; -import info.nightscout.androidaps.plugins.general.automation.actions.ActionNotification; -import info.nightscout.androidaps.plugins.general.automation.actions.ActionProfileSwitchPercent; -import info.nightscout.androidaps.plugins.general.automation.actions.ActionStartTempTarget; -import info.nightscout.androidaps.plugins.general.automation.actions.ActionStopTempTarget; public class ChooseActionDialog extends DialogFragment { @@ -36,17 +26,6 @@ public class ChooseActionDialog extends DialogFragment { private static OnClickListener mClickListener = null; - private static final List actionDummyObjects = new ArrayList() {{ - add(new ActionLoopDisable()); - add(new ActionLoopEnable()); - add(new ActionLoopResume()); - add(new ActionLoopSuspend()); - add(new ActionStartTempTarget()); - add(new ActionStopTempTarget()); - add(new ActionNotification()); - add(new ActionProfileSwitchPercent()); - }}; - private Unbinder mUnbinder; @BindView(R.id.radioGroup) @@ -66,7 +45,7 @@ public class ChooseActionDialog extends DialogFragment { View view = inflater.inflate(R.layout.automation_dialog_choose_action, container, false); mUnbinder = ButterKnife.bind(this, view); - for (Action a : actionDummyObjects) { + for (Action a : AutomationPlugin.actionDummyObjects) { RadioButton radioButton = new RadioButton(getContext()); radioButton.setText(a.friendlyName()); radioButton.setTag(a);