fix copy constructors in automation plugin

This commit is contained in:
Milos Kozak 2019-09-04 21:00:00 +02:00
parent d452d21c93
commit 139455747e
7 changed files with 20 additions and 19 deletions

View file

@ -25,8 +25,8 @@ public class InputDouble extends Element {
}; };
private double value; private double value;
double minValue; private double minValue;
double maxValue; private double maxValue;
private double step; private double step;
private DecimalFormat decimalFormat; private DecimalFormat decimalFormat;

View file

@ -20,6 +20,11 @@ public class InputDuration extends Element {
this.value = value; this.value = value;
} }
public InputDuration(InputDuration another) {
unit = another.unit;
value = another.value;
}
@Override @Override
public void addToLayout(LinearLayout root) { public void addToLayout(LinearLayout root) {
NumberPicker numberPicker = new NumberPicker(root.getContext(), null); NumberPicker numberPicker = new NumberPicker(root.getContext(), null);

View file

@ -19,7 +19,7 @@ public class InputTempTarget extends Element {
private double step; private double step;
private DecimalFormat decimalFormat; private DecimalFormat decimalFormat;
final TextWatcher textWatcher = new TextWatcher() { private final TextWatcher textWatcher = new TextWatcher() {
@Override @Override
public void afterTextChanged(Editable s) { public void afterTextChanged(Editable s) {
value = Math.max(minValue, value); value = Math.max(minValue, value);

View file

@ -11,8 +11,6 @@ import org.json.JSONObject;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.text.DecimalFormat;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R; import info.nightscout.androidaps.R;
import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.logging.L;
@ -28,9 +26,7 @@ import info.nightscout.androidaps.utils.T;
public class TriggerBolusAgo extends Trigger { public class TriggerBolusAgo extends Trigger {
private static Logger log = LoggerFactory.getLogger(L.AUTOMATION); private static Logger log = LoggerFactory.getLogger(L.AUTOMATION);
private final double step = 1; private InputDuration minutesAgo = new InputDuration(0, InputDuration.TimeUnit.MINUTES);
private DecimalFormat decimalFormat = new DecimalFormat("1");
public InputDuration minutesAgo = new InputDuration(0, InputDuration.TimeUnit.MINUTES);
private Comparator comparator = new Comparator(); private Comparator comparator = new Comparator();
public TriggerBolusAgo() { public TriggerBolusAgo() {
@ -39,7 +35,7 @@ public class TriggerBolusAgo extends Trigger {
private TriggerBolusAgo(TriggerBolusAgo triggerBolusAgo) { private TriggerBolusAgo(TriggerBolusAgo triggerBolusAgo) {
super(); super();
minutesAgo = new InputDuration(triggerBolusAgo.minutesAgo.getMinutes(), InputDuration.TimeUnit.MINUTES); minutesAgo = new InputDuration(triggerBolusAgo.minutesAgo);
lastRun = triggerBolusAgo.lastRun; lastRun = triggerBolusAgo.lastRun;
comparator = new Comparator(triggerBolusAgo.comparator); comparator = new Comparator(triggerBolusAgo.comparator);
} }

View file

@ -32,10 +32,8 @@ import info.nightscout.androidaps.utils.T;
public class TriggerCOB extends Trigger { public class TriggerCOB extends Trigger {
private static Logger log = LoggerFactory.getLogger(L.AUTOMATION); private static Logger log = LoggerFactory.getLogger(L.AUTOMATION);
private final int minValue = 0; private final int minValue = 0;
private final int maxValue = (int) (SP.getInt(R.string.key_treatmentssafety_maxcarbs, 48)); private final int maxValue = SP.getInt(R.string.key_treatmentssafety_maxcarbs, 48);
private final double step = 1; private InputDouble value = new InputDouble(0, (double) minValue, (double) maxValue, 1, new DecimalFormat("1"));
private DecimalFormat decimalFormat = new DecimalFormat("1");
private InputDouble value = new InputDouble(0, (double) minValue, (double) maxValue, step, decimalFormat);
private Comparator comparator = new Comparator(); private Comparator comparator = new Comparator();
public TriggerCOB() { public TriggerCOB() {

View file

@ -51,10 +51,11 @@ public class TriggerDelta extends Trigger {
private TriggerDelta(TriggerDelta triggerDelta) { private TriggerDelta(TriggerDelta triggerDelta) {
super(); super();
this.units = ProfileFunctions.getInstance().getProfileUnits();
initializer();
value = triggerDelta.value;
lastRun = triggerDelta.lastRun; lastRun = triggerDelta.lastRun;
this.units = triggerDelta.units;
deltaType = triggerDelta.deltaType;
value = new InputDelta(triggerDelta.value);
comparator = new Comparator(triggerDelta.comparator);
} }
public double getValue() { public double getValue() {

View file

@ -51,10 +51,11 @@ public class TriggerLocation extends Trigger {
private TriggerLocation(TriggerLocation triggerLocation) { private TriggerLocation(TriggerLocation triggerLocation) {
super(); super();
latitude = new InputDouble(triggerLocation.latitude.getValue(), -90d, +90d, 0.00001d, new DecimalFormat("0.00000")); latitude = new InputDouble(triggerLocation.latitude);
longitude = new InputDouble(triggerLocation.longitude.getValue(), -180d, +180d, 0.00001d, new DecimalFormat("0.00000")); longitude = new InputDouble(triggerLocation.longitude);
distance = new InputDouble(200d, 0, 100000, 10d, new DecimalFormat("0")); distance = new InputDouble(triggerLocation.distance);
lastRun = triggerLocation.lastRun; lastRun = triggerLocation.lastRun;
name = triggerLocation.name;
} }
@Override @Override