TriggerDelta default value 0
This commit is contained in:
parent
e6ae4f03d5
commit
022ca2fe6e
2 changed files with 18 additions and 38 deletions
|
@ -21,19 +21,6 @@ import info.nightscout.androidaps.utils.NumberPicker;
|
||||||
|
|
||||||
public class InputDelta extends Element {
|
public class InputDelta extends Element {
|
||||||
private Comparator.Compare compare = Comparator.Compare.IS_EQUAL;
|
private Comparator.Compare compare = Comparator.Compare.IS_EQUAL;
|
||||||
final TextWatcher textWatcher = new TextWatcher() {
|
|
||||||
@Override
|
|
||||||
public void afterTextChanged(Editable s) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
public enum DeltaType {
|
public enum DeltaType {
|
||||||
DELTA,
|
DELTA,
|
||||||
|
@ -122,7 +109,7 @@ public class InputDelta extends Element {
|
||||||
spinner.setSelection(this.deltaType.ordinal());
|
spinner.setSelection(this.deltaType.ordinal());
|
||||||
// root.addView(spinner);
|
// root.addView(spinner);
|
||||||
numberPicker = new NumberPicker(root.getContext(), null);
|
numberPicker = new NumberPicker(root.getContext(), null);
|
||||||
numberPicker.setParams(value, minValue, maxValue, step, decimalFormat, true, null, textWatcher);
|
numberPicker.setParams(value, minValue, maxValue, step, decimalFormat, true, null, null);
|
||||||
numberPicker.setOnValueChangedListener(value -> this.value = value);
|
numberPicker.setOnValueChangedListener(value -> this.value = value);
|
||||||
LinearLayout l = new LinearLayout(root.getContext());
|
LinearLayout l = new LinearLayout(root.getContext());
|
||||||
l.setOrientation(LinearLayout.VERTICAL);
|
l.setOrientation(LinearLayout.VERTICAL);
|
||||||
|
|
|
@ -33,15 +33,15 @@ import info.nightscout.androidaps.utils.T;
|
||||||
|
|
||||||
public class TriggerDelta extends Trigger {
|
public class TriggerDelta extends Trigger {
|
||||||
private static Logger log = LoggerFactory.getLogger(L.AUTOMATION);
|
private static Logger log = LoggerFactory.getLogger(L.AUTOMATION);
|
||||||
private double minValue = 0d;
|
|
||||||
private double maxValue = 1d;
|
private final int MMOL_MAX = 4;
|
||||||
private double step = 1;
|
private final int MGDL_MAX = 72;
|
||||||
private DecimalFormat decimalFormat = new DecimalFormat("1");
|
|
||||||
private String units;
|
private String units;
|
||||||
private DeltaType deltaType;
|
private DeltaType deltaType;
|
||||||
|
|
||||||
private InputDelta value = new InputDelta( (double) minValue,(double) minValue, (double) maxValue, step, decimalFormat, deltaType);
|
private InputDelta value;
|
||||||
private Comparator comparator = new Comparator();
|
private Comparator comparator;
|
||||||
|
|
||||||
public TriggerDelta() {
|
public TriggerDelta() {
|
||||||
super();
|
super();
|
||||||
|
@ -62,6 +62,16 @@ public class TriggerDelta extends Trigger {
|
||||||
return value.getValue();
|
return value.getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void initializer() {
|
||||||
|
this.deltaType = DeltaType.DELTA;
|
||||||
|
comparator = new Comparator();
|
||||||
|
if (units.equals(Constants.MMOL))
|
||||||
|
value = new InputDelta(0, -MMOL_MAX, MMOL_MAX, 0.1d, new DecimalFormat("0.1"), DeltaType.DELTA);
|
||||||
|
else
|
||||||
|
value = new InputDelta(0, -MGDL_MAX, MGDL_MAX, 0.1d, new DecimalFormat("1"), DeltaType.DELTA);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public DeltaType getType() {
|
public DeltaType getType() {
|
||||||
return deltaType;
|
return deltaType;
|
||||||
}
|
}
|
||||||
|
@ -169,23 +179,6 @@ public class TriggerDelta extends Trigger {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
void initializer(){
|
|
||||||
if (this.units.equals(Constants.MMOL)) {
|
|
||||||
this.maxValue = 4d;
|
|
||||||
this.minValue = -4d;
|
|
||||||
this.step = 0.1d;
|
|
||||||
this.decimalFormat = new DecimalFormat("0.1");
|
|
||||||
this.deltaType = DeltaType.DELTA;
|
|
||||||
} else {
|
|
||||||
this.maxValue = 72d;
|
|
||||||
this.minValue = -72d;
|
|
||||||
this.step = 1d;
|
|
||||||
this.deltaType = DeltaType.DELTA;
|
|
||||||
}
|
|
||||||
value = new InputDelta( (double) minValue,(double) minValue, (double) maxValue, step, decimalFormat, deltaType);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
TriggerDelta lastRun(long lastRun) {
|
TriggerDelta lastRun(long lastRun) {
|
||||||
this.lastRun = lastRun;
|
this.lastRun = lastRun;
|
||||||
return this;
|
return this;
|
||||||
|
|
Loading…
Reference in a new issue