From a8ff04b5d77c32d522b3db5bb245598fbd5faba4 Mon Sep 17 00:00:00 2001 From: Erik Johansson Date: Thu, 21 Jun 2018 18:08:30 +0200 Subject: [PATCH] Convert goal weight to user's unit before plotting in graph Fix #292 --- .../com/health/openscale/gui/fragments/GraphFragment.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/android_app/app/src/main/java/com/health/openscale/gui/fragments/GraphFragment.java b/android_app/app/src/main/java/com/health/openscale/gui/fragments/GraphFragment.java index 18b1b1c7..43d21dcc 100644 --- a/android_app/app/src/main/java/com/health/openscale/gui/fragments/GraphFragment.java +++ b/android_app/app/src/main/java/com/health/openscale/gui/fragments/GraphFragment.java @@ -41,6 +41,8 @@ import android.widget.TextView; import com.health.openscale.R; import com.health.openscale.core.OpenScale; import com.health.openscale.core.datatypes.ScaleMeasurement; +import com.health.openscale.core.datatypes.ScaleUser; +import com.health.openscale.core.utils.Converters; import com.health.openscale.core.utils.PolynomialFitter; import com.health.openscale.gui.activities.DataEntryActivity; import com.health.openscale.gui.views.BMRMeasurementView; @@ -412,7 +414,8 @@ public class GraphFragment extends Fragment implements FragmentUpdateListener { if (prefs.getBoolean("goalLine", true)) { Stack valuesGoalLine = new Stack<>(); - float goalWeight = openScale.getSelectedScaleUser().getGoalWeight(); + final ScaleUser user = openScale.getSelectedScaleUser(); + float goalWeight = Converters.fromKilogram(user.getGoalWeight(), user.getScaleUnit()); valuesGoalLine.push(new PointValue(0, goalWeight)); valuesGoalLine.push(new PointValue(maxDays, goalWeight));