mirror of
https://github.com/oliexdev/openScale.git
synced 2025-08-21 07:51:46 +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:
@@ -43,6 +43,7 @@ import com.health.openscale.gui.views.DateMeasurementView;
|
|||||||
import com.health.openscale.gui.views.MeasurementView;
|
import com.health.openscale.gui.views.MeasurementView;
|
||||||
import com.health.openscale.gui.views.MeasurementViewUpdateListener;
|
import com.health.openscale.gui.views.MeasurementViewUpdateListener;
|
||||||
import com.health.openscale.gui.views.TimeMeasurementView;
|
import com.health.openscale.gui.views.TimeMeasurementView;
|
||||||
|
import com.health.openscale.gui.views.WeightMeasurementView;
|
||||||
|
|
||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
@@ -446,6 +447,17 @@ public class DataEntryActivity extends AppCompatActivity {
|
|||||||
view.saveTo(scaleMeasurement);
|
view.saveTo(scaleMeasurement);
|
||||||
isDirty = true;
|
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(
|
txtDataNr.setText(DateFormat.getDateTimeInstance(
|
||||||
DateFormat.LONG, DateFormat.SHORT).format(scaleMeasurement.getDateTime()));
|
DateFormat.LONG, DateFormat.SHORT).format(scaleMeasurement.getDateTime()));
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user