TriggerDelta default value 0

This commit is contained in:
Milos Kozak 2019-08-27 19:28:28 +02:00
parent e6ae4f03d5
commit 022ca2fe6e
2 changed files with 18 additions and 38 deletions

View file

@ -21,19 +21,6 @@ import info.nightscout.androidaps.utils.NumberPicker;
public class InputDelta extends Element {
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 {
DELTA,
@ -122,7 +109,7 @@ public class InputDelta extends Element {
spinner.setSelection(this.deltaType.ordinal());
// root.addView(spinner);
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);
LinearLayout l = new LinearLayout(root.getContext());
l.setOrientation(LinearLayout.VERTICAL);

View file

@ -33,15 +33,15 @@ import info.nightscout.androidaps.utils.T;
public class TriggerDelta extends Trigger {
private static Logger log = LoggerFactory.getLogger(L.AUTOMATION);
private double minValue = 0d;
private double maxValue = 1d;
private double step = 1;
private DecimalFormat decimalFormat = new DecimalFormat("1");
private final int MMOL_MAX = 4;
private final int MGDL_MAX = 72;
private String units;
private DeltaType deltaType;
private InputDelta value = new InputDelta( (double) minValue,(double) minValue, (double) maxValue, step, decimalFormat, deltaType);
private Comparator comparator = new Comparator();
private InputDelta value;
private Comparator comparator;
public TriggerDelta() {
super();
@ -62,6 +62,16 @@ public class TriggerDelta extends Trigger {
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() {
return deltaType;
}
@ -150,7 +160,7 @@ public class TriggerDelta extends Trigger {
@Override
public Optional<Integer> icon() {
return Optional.of(R.drawable.icon_auto_delta);
return Optional.of(R.drawable.icon_auto_delta);
}
@Override
@ -169,23 +179,6 @@ public class TriggerDelta extends Trigger {
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) {
this.lastRun = lastRun;
return this;