From 74d954dc382a0d9d4cab4d9620a86d0deff8b8e7 Mon Sep 17 00:00:00 2001 From: OliE Date: Fri, 19 Jan 2018 16:09:14 +0100 Subject: [PATCH] removed setConvertedWeight (..) in MainActivity --- .../openscale/core/bluetooth/BluetoothDigooDGSO38H.java | 4 ++-- .../health/openscale/core/bluetooth/BluetoothMiScale.java | 5 ++++- .../health/openscale/core/bluetooth/BluetoothMiScale2.java | 3 ++- .../src/main/java/com/health/openscale/gui/MainActivity.java | 2 -- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/android_app/app/src/main/java/com/health/openscale/core/bluetooth/BluetoothDigooDGSO38H.java b/android_app/app/src/main/java/com/health/openscale/core/bluetooth/BluetoothDigooDGSO38H.java index 43e16dec..8a694a42 100644 --- a/android_app/app/src/main/java/com/health/openscale/core/bluetooth/BluetoothDigooDGSO38H.java +++ b/android_app/app/src/main/java/com/health/openscale/core/bluetooth/BluetoothDigooDGSO38H.java @@ -100,10 +100,10 @@ public class BluetoothDigooDGSO38H extends BluetoothCommunication { final byte ctrlByte = weightBytes[5]; final boolean allValues = isBitSet(ctrlByte, 1); final boolean weightStabilized = isBitSet(ctrlByte, 0); + final ScaleUser selectedUser = OpenScale.getInstance(context).getSelectedScaleUser(); if (weightStabilized) { //The weight is stabilized, now we want to measure all available values - final ScaleUser selectedUser = OpenScale.getInstance(context).getSelectedScaleUser(); byte gender = selectedUser.isMale() ? (byte)0x00: (byte)0x01; byte height = (byte) (selectedUser.getBodyHeight() & 0xFF); byte age = (byte)(selectedUser.getAge(new Date()) & 0xff); @@ -152,7 +152,7 @@ public class BluetoothDigooDGSO38H extends BluetoothCommunication { scaleBtData.setWater(water); scaleBtData.setBone(boneWeight); } - scaleBtData.setWeight(weight); + scaleBtData.setConvertedWeight(weight, selectedUser.getScaleUnit()); addScaleData(scaleBtData); } } diff --git a/android_app/app/src/main/java/com/health/openscale/core/bluetooth/BluetoothMiScale.java b/android_app/app/src/main/java/com/health/openscale/core/bluetooth/BluetoothMiScale.java index 1e0f701d..e8179d96 100644 --- a/android_app/app/src/main/java/com/health/openscale/core/bluetooth/BluetoothMiScale.java +++ b/android_app/app/src/main/java/com/health/openscale/core/bluetooth/BluetoothMiScale.java @@ -23,7 +23,9 @@ import android.content.SharedPreferences; import android.preference.PreferenceManager; import android.util.Log; +import com.health.openscale.core.OpenScale; import com.health.openscale.core.datatypes.ScaleMeasurement; +import com.health.openscale.core.datatypes.ScaleUser; import java.text.ParseException; import java.text.SimpleDateFormat; @@ -238,9 +240,10 @@ public class BluetoothMiScale extends BluetoothCommunication { // Is the year plausible? Check if the year is in the range of 20 years... if (validateDate(date_time, 20)) { + final ScaleUser selectedUser = OpenScale.getInstance(context).getSelectedScaleUser(); ScaleMeasurement scaleBtData = new ScaleMeasurement(); - scaleBtData.setWeight(weight); + scaleBtData.setConvertedWeight(weight, selectedUser.getScaleUnit()); scaleBtData.setDateTime(date_time); addScaleData(scaleBtData); diff --git a/android_app/app/src/main/java/com/health/openscale/core/bluetooth/BluetoothMiScale2.java b/android_app/app/src/main/java/com/health/openscale/core/bluetooth/BluetoothMiScale2.java index ec00e1ca..54255cf6 100644 --- a/android_app/app/src/main/java/com/health/openscale/core/bluetooth/BluetoothMiScale2.java +++ b/android_app/app/src/main/java/com/health/openscale/core/bluetooth/BluetoothMiScale2.java @@ -211,9 +211,10 @@ public class BluetoothMiScale2 extends BluetoothCommunication { // Is the year plausible? Check if the year is in the range of 20 years... if (validateDate(date_time, 20)) { + final ScaleUser selectedUser = OpenScale.getInstance(context).getSelectedScaleUser(); ScaleMeasurement scaleBtData = new ScaleMeasurement(); - scaleBtData.setWeight(weight); + scaleBtData.setConvertedWeight(weight, selectedUser.getScaleUnit()); scaleBtData.setDateTime(date_time); addScaleData(scaleBtData); diff --git a/android_app/app/src/main/java/com/health/openscale/gui/MainActivity.java b/android_app/app/src/main/java/com/health/openscale/gui/MainActivity.java index 8d43c95e..919a219f 100644 --- a/android_app/app/src/main/java/com/health/openscale/gui/MainActivity.java +++ b/android_app/app/src/main/java/com/health/openscale/gui/MainActivity.java @@ -376,8 +376,6 @@ public class MainActivity extends AppCompatActivity { setBluetoothStatusIcon(R.drawable.ic_bluetooth_connection_success); ScaleMeasurement scaleBtData = (ScaleMeasurement) msg.obj; - // scaleBtData.setConvertedWeight(scaleBtData.getWeight(), OpenScale.getInstance(getApplicationContext()).getSelectedScaleUser().getScaleUnit()); - OpenScale.getInstance(getApplicationContext()).addScaleData(scaleBtData); break; case BT_INIT_PROCESS: