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

Minor code cleanup

This commit is contained in:
Erik Johansson
2018-04-16 21:34:01 +02:00
parent 8fa84b2a61
commit caee1bb3f4
9 changed files with 6 additions and 21 deletions

View File

@@ -319,7 +319,7 @@ public class OpenScale {
for (int i = 0; i < scaleUsers.size(); i++) { for (int i = 0; i < scaleUsers.size(); i++) {
List<ScaleMeasurement> scaleUserData = measurementDAO.getAll(scaleUsers.get(i).getId()); List<ScaleMeasurement> scaleUserData = measurementDAO.getAll(scaleUsers.get(i).getId());
float lastWeight = 0; float lastWeight;
if (scaleUserData.size() > 0) { if (scaleUserData.size() > 0) {
lastWeight = scaleUserData.get(0).getWeight(); lastWeight = scaleUserData.get(0).getWeight();

View File

@@ -196,8 +196,6 @@ public class BluetoothMiScale extends BluetoothCommunication {
private void parseBytes(byte[] weightBytes) { private void parseBytes(byte[] weightBytes) {
try { try {
float weight = 0.0f;
final byte ctrlByte = weightBytes[0]; final byte ctrlByte = weightBytes[0];
final boolean isWeightRemoved = isBitSet(ctrlByte, 7); final boolean isWeightRemoved = isBitSet(ctrlByte, 7);
@@ -224,6 +222,7 @@ public class BluetoothMiScale extends BluetoothCommunication {
final int min = (int) weightBytes[8]; final int min = (int) weightBytes[8];
final int sec = (int) weightBytes[9]; final int sec = (int) weightBytes[9];
float weight;
if (isLBSUnit || isCattyUnit) { if (isLBSUnit || isCattyUnit) {
weight = (float) (((weightBytes[2] & 0xFF) << 8) | (weightBytes[1] & 0xFF)) / 100.0f; weight = (float) (((weightBytes[2] & 0xFF) << 8) | (weightBytes[1] & 0xFF)) / 100.0f;
} else { } else {

View File

@@ -175,8 +175,6 @@ public class BluetoothMiScale2 extends BluetoothCommunication {
private void parseBytes(byte[] weightBytes) { private void parseBytes(byte[] weightBytes) {
try { try {
float weight = 0.0f;
final byte ctrlByte0 = weightBytes[0]; final byte ctrlByte0 = weightBytes[0];
final byte ctrlByte1 = weightBytes[1]; final byte ctrlByte1 = weightBytes[1];
@@ -195,6 +193,7 @@ public class BluetoothMiScale2 extends BluetoothCommunication {
final int min = (int) weightBytes[7]; final int min = (int) weightBytes[7];
final int sec = (int) weightBytes[8]; final int sec = (int) weightBytes[8];
float weight;
if (isLBSUnit || isCattyUnit) { if (isLBSUnit || isCattyUnit) {
weight = (float) (((weightBytes[12] & 0xFF) << 8) | (weightBytes[11] & 0xFF)) / 100.0f; weight = (float) (((weightBytes[12] & 0xFF) << 8) | (weightBytes[11] & 0xFF)) / 100.0f;
} else { } else {

View File

@@ -272,7 +272,7 @@ public class ScaleMeasurement implements Cloneable {
} }
public float getBMR(ScaleUser scaleUser) { public float getBMR(ScaleUser scaleUser) {
float bmr = 0.0f; float bmr;
// BMR formula by Mifflin, St Jeor et al: A new predictive equation for resting energy expenditure in healthy individuals // BMR formula by Mifflin, St Jeor et al: A new predictive equation for resting energy expenditure in healthy individuals
if (scaleUser.getGender().isMale()) { if (scaleUser.getGender().isMale()) {

View File

@@ -24,13 +24,6 @@ public class EvaluationResult {
public float highLimit; public float highLimit;
public EVAL_STATE eval_state; public EVAL_STATE eval_state;
public EvaluationResult() {
this.value = -1.0f;
this.lowLimit = -1.0f;
this.highLimit = -1.0f;
this.eval_state = EVAL_STATE.UNDEFINED;
}
public EvaluationResult(float value, float lowLimit, float highLimit, EVAL_STATE eval_state) public EvaluationResult(float value, float lowLimit, float highLimit, EVAL_STATE eval_state)
{ {
this.value = value; this.value = value;
@@ -38,5 +31,4 @@ public class EvaluationResult {
this.highLimit = highLimit; this.highLimit = highLimit;
this.eval_state = eval_state; this.eval_state = eval_state;
} }
} }

View File

@@ -168,8 +168,8 @@ public class EvaluationSheet {
public EvaluationResult evaluateWeight(float weight) { public EvaluationResult evaluateWeight(float weight) {
float body_height_squared = (evalUser.getBodyHeight() / 100.0f) * (evalUser.getBodyHeight() / 100.0f); float body_height_squared = (evalUser.getBodyHeight() / 100.0f) * (evalUser.getBodyHeight() / 100.0f);
float lowLimit = 0.0f; float lowLimit;
float highLimit = 0.0f; float highLimit;
if (evalUser.getGender().isMale()) { if (evalUser.getGender().isMale()) {
lowLimit = body_height_squared * 20.0f; lowLimit = body_height_squared * 20.0f;

View File

@@ -46,7 +46,6 @@ import android.support.v7.widget.Toolbar;
import android.util.Log; import android.util.Log;
import android.view.Menu; import android.view.Menu;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.View;
import android.widget.Toast; import android.widget.Toast;
import com.health.openscale.BuildConfig; import com.health.openscale.BuildConfig;

View File

@@ -242,8 +242,6 @@ public class TableFragment extends Fragment implements FragmentUpdateListener {
private Spanned[][] stringCache; private Spanned[][] stringCache;
private ArrayList<HashMap<Integer, Spanned>> dataList;
public void setMeasurements(List<MeasurementView> visibleMeasurements, public void setMeasurements(List<MeasurementView> visibleMeasurements,
List<ScaleMeasurement> scaleMeasurements, List<ScaleMeasurement> scaleMeasurements,
int maxSize) { int maxSize) {

View File

@@ -31,8 +31,6 @@ import java.util.List;
import java.util.Set; import java.util.Set;
public class GeneralPreferences extends PreferenceFragment implements SharedPreferences.OnSharedPreferenceChangeListener { public class GeneralPreferences extends PreferenceFragment implements SharedPreferences.OnSharedPreferenceChangeListener {
private static final String PREFERENCE_KEY_APP_THEME = "app_theme";
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);