1
0
mirror of https://github.com/oliexdev/openScale.git synced 2025-08-20 07:21:40 +02:00

Save all values when weight is updated

If weight is updated and some measurements are shown as absolute
values, but saved as percentages, then we must re-save them using the
new weight. Otherwise the measurements will change without actually
having changed.
This commit is contained in:
Erik Johansson
2018-03-07 20:42:21 +01:00
parent 5e058f4e3c
commit e151cc885c

View File

@@ -43,6 +43,7 @@ import com.health.openscale.gui.views.DateMeasurementView;
import com.health.openscale.gui.views.MeasurementView;
import com.health.openscale.gui.views.MeasurementViewUpdateListener;
import com.health.openscale.gui.views.TimeMeasurementView;
import com.health.openscale.gui.views.WeightMeasurementView;
import java.text.DateFormat;
import java.util.Date;
@@ -446,6 +447,17 @@ public class DataEntryActivity extends AppCompatActivity {
view.saveTo(scaleMeasurement);
isDirty = true;
// When weight is updated we may need to re-save some values that are stored
// as percentages, but that the user may have set up to be shown as absolute.
// Otherwise that measurement (e.g. fat) may change when weight is updated.
if (view instanceof WeightMeasurementView) {
for (MeasurementView measurement : dataEntryMeasurements) {
if (measurement != view) {
measurement.saveTo(scaleMeasurement);
}
}
}
txtDataNr.setText(DateFormat.getDateTimeInstance(
DateFormat.LONG, DateFormat.SHORT).format(scaleMeasurement.getDateTime()));