From 6978c488e1b2836928980457c2bad5be75aa5917 Mon Sep 17 00:00:00 2001 From: Erik Johansson Date: Wed, 18 Apr 2018 22:15:25 +0200 Subject: [PATCH] ADd getAge() method overload not taking a Date --- .../openscale/core/bluetooth/BluetoothDigooDGSO38H.java | 2 +- .../core/bluetooth/BluetoothExcelvanCF369BLE.java | 2 +- .../openscale/core/bluetooth/BluetoothExingtechY1.java | 2 +- .../com/health/openscale/core/bluetooth/BluetoothMGB.java | 2 +- .../openscale/core/bluetooth/BluetoothYunmaiSE_Mini.java | 2 +- .../com/health/openscale/core/datatypes/ScaleUser.java | 8 +++++++- 6 files changed, 12 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 93384699..25830eb8 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 @@ -97,7 +97,7 @@ public class BluetoothDigooDGSO38H extends BluetoothCommunication { //The weight is stabilized, now we want to measure all available values byte gender = selectedUser.getGender().isMale() ? (byte)0x00: (byte)0x01; byte height = (byte) (selectedUser.getBodyHeight() & 0xFF); - byte age = (byte)(selectedUser.getAge(new Date()) & 0xff); + byte age = (byte)(selectedUser.getAge() & 0xff); byte unit = 0x01; // kg switch (selectedUser.getScaleUnit()) { case LB: diff --git a/android_app/app/src/main/java/com/health/openscale/core/bluetooth/BluetoothExcelvanCF369BLE.java b/android_app/app/src/main/java/com/health/openscale/core/bluetooth/BluetoothExcelvanCF369BLE.java index 7b04a100..c7d9ca68 100644 --- a/android_app/app/src/main/java/com/health/openscale/core/bluetooth/BluetoothExcelvanCF369BLE.java +++ b/android_app/app/src/main/java/com/health/openscale/core/bluetooth/BluetoothExcelvanCF369BLE.java @@ -58,7 +58,7 @@ public class BluetoothExcelvanCF369BLE extends BluetoothCommunication { byte sex = selectedUser.getGender().isMale() ? (byte)0x01 : (byte)0x00; // 01 - male; 00 - female byte height = (byte)(selectedUser.getBodyHeight() & 0xff); // cm - byte age = (byte)(selectedUser.getAge(new Date()) & 0xff); + byte age = (byte)(selectedUser.getAge() & 0xff); byte unit = 0x01; // kg switch (selectedUser.getScaleUnit()) { diff --git a/android_app/app/src/main/java/com/health/openscale/core/bluetooth/BluetoothExingtechY1.java b/android_app/app/src/main/java/com/health/openscale/core/bluetooth/BluetoothExingtechY1.java index e4257584..b45d0282 100644 --- a/android_app/app/src/main/java/com/health/openscale/core/bluetooth/BluetoothExingtechY1.java +++ b/android_app/app/src/main/java/com/health/openscale/core/bluetooth/BluetoothExingtechY1.java @@ -53,7 +53,7 @@ public class BluetoothExingtechY1 extends BluetoothCommunication { byte gender = selectedUser.getGender().isMale() ? (byte)0x00 : (byte)0x01; // 00 - male; 01 - female byte height = (byte)(selectedUser.getBodyHeight() & 0xff); // cm - byte age = (byte)(selectedUser.getAge(new Date()) & 0xff); + byte age = (byte)(selectedUser.getAge() & 0xff); int userId = selectedUser.getId(); diff --git a/android_app/app/src/main/java/com/health/openscale/core/bluetooth/BluetoothMGB.java b/android_app/app/src/main/java/com/health/openscale/core/bluetooth/BluetoothMGB.java index c313cea3..f41b3498 100644 --- a/android_app/app/src/main/java/com/health/openscale/core/bluetooth/BluetoothMGB.java +++ b/android_app/app/src/main/java/com/health/openscale/core/bluetooth/BluetoothMGB.java @@ -101,7 +101,7 @@ public class BluetoothMGB extends BluetoothCommunication { break; case 3: - writeCfg(0xFB, (user.getGender().isMale() ? 1 : 2), user.getAge(new Date()), user.getBodyHeight()); + writeCfg(0xFB, (user.getGender().isMale() ? 1 : 2), user.getAge(), user.getBodyHeight()); break; case 4: diff --git a/android_app/app/src/main/java/com/health/openscale/core/bluetooth/BluetoothYunmaiSE_Mini.java b/android_app/app/src/main/java/com/health/openscale/core/bluetooth/BluetoothYunmaiSE_Mini.java index 663fcf85..1a36a4a7 100644 --- a/android_app/app/src/main/java/com/health/openscale/core/bluetooth/BluetoothYunmaiSE_Mini.java +++ b/android_app/app/src/main/java/com/health/openscale/core/bluetooth/BluetoothYunmaiSE_Mini.java @@ -64,7 +64,7 @@ public class BluetoothYunmaiSE_Mini extends BluetoothCommunication { byte[] user_add_or_query = new byte[]{ (byte) 0x0d, (byte) 0x12, (byte) 0x10, (byte) 0x01, (byte) 0x00, (byte) 0x00, userId[0], userId[1], (byte) selectedUser.getBodyHeight(), sex, - (byte) selectedUser.getAge(new Date()), (byte) 0x55, (byte) 0x5a, (byte) 0x00, + (byte) selectedUser.getAge(), (byte) 0x55, (byte) 0x5a, (byte) 0x00, (byte)0x00, display_unit, (byte) 0x03, (byte) 0x00}; user_add_or_query[17] = xor_checksum(user_add_or_query); writeBytes(WEIGHT_CMD_SERVICE, WEIGHT_CMD_CHARACTERISTIC, user_add_or_query); diff --git a/android_app/app/src/main/java/com/health/openscale/core/datatypes/ScaleUser.java b/android_app/app/src/main/java/com/health/openscale/core/datatypes/ScaleUser.java index fcb5e291..088c5c51 100644 --- a/android_app/app/src/main/java/com/health/openscale/core/datatypes/ScaleUser.java +++ b/android_app/app/src/main/java/com/health/openscale/core/datatypes/ScaleUser.java @@ -128,7 +128,9 @@ public class ScaleUser { public int getAge(Date todayDate) { Calendar calToday = Calendar.getInstance(); - calToday.setTime(todayDate); + if (todayDate != null) { + calToday.setTime(todayDate); + } Calendar calBirthday = Calendar.getInstance(); calBirthday.setTime(birthday); @@ -136,6 +138,10 @@ public class ScaleUser { return DateTimeHelpers.yearsBetween(calBirthday, calToday); } + public int getAge() { + return getAge(null); + } + public void setInitialWeight(float weight) { this.initialWeight = weight; }