1
0
mirror of https://github.com/oliexdev/openScale.git synced 2025-08-24 01:03:20 +02:00

Make incValue and decValue handle edge case better

Instead of blocking a dec when the value is 0.01, set it to 0. Similar
for incValue.
This commit is contained in:
Erik Johansson
2017-11-22 22:51:03 +01:00
parent 5002f739c1
commit 82ec4863ef

View File

@@ -219,20 +219,14 @@ public abstract class MeasurementView extends TableLayout {
} }
public void incValue() { public void incValue() {
float incValue = getValue() + 0.1f; float incValue = Math.min(getMaxValue(), getValue() + 0.1f);
if (incValue <= getMaxValue()) {
setValueOnView(dateTime, incValue); setValueOnView(dateTime, incValue);
} }
}
public void decValue() { public void decValue() {
float decValue = getValue() - 0.1f; float decValue = Math.max(0.0f, getValue() - 0.1f);
if (decValue >= 0) {
setValueOnView(dateTime, decValue); setValueOnView(dateTime, decValue);
} }
}
public String getValueAsString() { public String getValueAsString() {
return value; return value;