relocate trigger dummy objects

This commit is contained in:
Milos Kozak 2019-07-22 16:28:53 +02:00
parent d25f6f07b0
commit c3b90275aa
3 changed files with 22 additions and 33 deletions

View file

@ -16,6 +16,7 @@ import info.nightscout.androidaps.plugins.bus.RxBus
import info.nightscout.androidaps.plugins.general.automation.actions.*
import info.nightscout.androidaps.plugins.general.automation.events.EventAutomationDataChanged
import info.nightscout.androidaps.plugins.general.automation.events.EventAutomationUpdateGui
import info.nightscout.androidaps.plugins.general.automation.triggers.*
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventAutosensCalculationFinished
import info.nightscout.androidaps.queue.Callback
import info.nightscout.androidaps.services.LocationService
@ -195,4 +196,21 @@ object AutomationPlugin : PluginBase(PluginDescription()
)
}
fun getTriggerDummyObjects(): List<Trigger> {
return listOf(
TriggerTime(),
TriggerRecurringTime(),
TriggerBg(),
TriggerDelta(),
TriggerIob(),
TriggerCOB(),
TriggerProfilePercent(),
TriggerTempTarget(),
TriggerWifiSsid(),
TriggerLocation(),
TriggerAutosensValue(),
TriggerBolusAgo()
)
}
}

View file

@ -10,27 +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.triggers.Trigger;
import info.nightscout.androidaps.plugins.general.automation.triggers.TriggerAutosensValue;
import info.nightscout.androidaps.plugins.general.automation.triggers.TriggerBg;
import info.nightscout.androidaps.plugins.general.automation.triggers.TriggerBolusAgo;
import info.nightscout.androidaps.plugins.general.automation.triggers.TriggerCOB;
import info.nightscout.androidaps.plugins.general.automation.triggers.TriggerDelta;
import info.nightscout.androidaps.plugins.general.automation.triggers.TriggerIob;
import info.nightscout.androidaps.plugins.general.automation.triggers.TriggerLocation;
import info.nightscout.androidaps.plugins.general.automation.triggers.TriggerProfilePercent;
import info.nightscout.androidaps.plugins.general.automation.triggers.TriggerRecurringTime;
import info.nightscout.androidaps.plugins.general.automation.triggers.TriggerTempTarget;
import info.nightscout.androidaps.plugins.general.automation.triggers.TriggerTime;
import info.nightscout.androidaps.plugins.general.automation.triggers.TriggerWifiSsid;
public class ChooseTriggerDialog extends DialogFragment {
@ -38,25 +24,10 @@ public class ChooseTriggerDialog extends DialogFragment {
void onClick(Trigger newTriggerObject);
}
private static final List<Trigger> triggerDummyObjects = new ArrayList<Trigger>() {{
add(new TriggerTime());
add(new TriggerRecurringTime());
add(new TriggerBg());
add(new TriggerDelta());
add(new TriggerIob());
add(new TriggerCOB());
add(new TriggerProfilePercent());
add(new TriggerTempTarget());
add(new TriggerWifiSsid());
add(new TriggerLocation());
add(new TriggerAutosensValue());
add(new TriggerBolusAgo());
}};
private Unbinder mUnbinder;
private OnClickListener mClickListener = null;
@BindView(R.id.radioGroup)
@BindView(R.id.automation_chooseTriggerRadioGroup)
RadioGroup mRadioGroup;
public static ChooseTriggerDialog newInstance() {
@ -73,7 +44,7 @@ public class ChooseTriggerDialog extends DialogFragment {
View view = inflater.inflate(R.layout.automation_dialog_choose_trigger, container, false);
mUnbinder = ButterKnife.bind(this, view);
for (Trigger t : triggerDummyObjects) {
for (Trigger t : AutomationPlugin.INSTANCE.getTriggerDummyObjects()) {
RadioButton radioButton = new RadioButton(getContext());
radioButton.setText(t.friendlyName());
radioButton.setTag(t);

View file

@ -18,7 +18,7 @@
android:text="@string/please_choose_a_trigger_type" />
<RadioGroup
android:id="@+id/radioGroup"
android:id="@+id/automation_chooseTriggerRadioGroup"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginVertical="5dp" />