1
0
mirror of https://github.com/oliexdev/openScale.git synced 2025-08-11 11:14:03 +02:00

set max and min range value on the linear gauge view to float and change the waist-hip ratio range from 0.5 to 1.5

This commit is contained in:
OliE
2017-03-04 13:55:50 +01:00
parent 6eeb5f962f
commit 2573c599bb
2 changed files with 29 additions and 29 deletions

View File

@@ -54,8 +54,8 @@ public class LinearGaugeView extends View {
private Paint infoTextPaint; private Paint infoTextPaint;
private float value; private float value;
private int minValue; private float minValue;
private int maxValue; private float maxValue;
private float firstLimit; private float firstLimit;
private float secondLimit; private float secondLimit;
@@ -109,13 +109,13 @@ public class LinearGaugeView extends View {
return; return;
} }
firstPercent = (firstLimit / (float)maxValue) * 100.0f; firstPercent = (firstLimit / maxValue) * 100.0f;
firstPos = (getWidth() / 100.0f) * firstPercent; firstPos = (getWidth() / 100.0f) * firstPercent;
secondPercent = (secondLimit / (float)maxValue) * 100.0f; secondPercent = (secondLimit / maxValue) * 100.0f;
secondPos = (getWidth() / 100.0f) * secondPercent; secondPos = (getWidth() / 100.0f) * secondPercent;
valuePercent = (value / (float)maxValue) * 100.0f; valuePercent = (value / maxValue) * 100.0f;
valuePos = (getWidth() / 100.0f) * valuePercent; valuePos = (getWidth() / 100.0f) * valuePercent;
// Bar // Bar
@@ -136,7 +136,7 @@ public class LinearGaugeView extends View {
canvas.drawRect(getWidth()-lineThickness, (getHeight() / 2.0f) - (limitLineHeight / 2.0f), getWidth(), (getHeight() / 2.0f) + (limitLineHeight / 2.0f), textPaint); canvas.drawRect(getWidth()-lineThickness, (getHeight() / 2.0f) - (limitLineHeight / 2.0f), getWidth(), (getHeight() / 2.0f) + (limitLineHeight / 2.0f), textPaint);
// Text // Text
canvas.drawText(Integer.toString(minValue), 0.0f, (getHeight() / 2.0f) - (barHeight / 2.0f) - textOffset, textPaint); canvas.drawText(Float.toString(minValue), 0.0f, (getHeight() / 2.0f) - (barHeight / 2.0f) - textOffset, textPaint);
if (firstLimit > 0) { if (firstLimit > 0) {
canvas.drawText(Float.toString(firstLimit), firstPos - 5.0f, (getHeight() / 2.0f) - (barHeight / 2.0f) - textOffset, textPaint); canvas.drawText(Float.toString(firstLimit), firstPos - 5.0f, (getHeight() / 2.0f) - (barHeight / 2.0f) - textOffset, textPaint);
} }
@@ -198,7 +198,7 @@ public class LinearGaugeView extends View {
setMeasuredDimension(width, height); setMeasuredDimension(width, height);
} }
public void setMinMaxValue(int min, int max) { public void setMinMaxValue(float min, float max) {
minValue = min; minValue = min;
maxValue = max; maxValue = max;
invalidate(); invalidate();

View File

@@ -53,9 +53,9 @@ abstract class Measurement {
abstract EvaluationResult evaluateSheet(EvaluationSheet evalSheet, float value); abstract EvaluationResult evaluateSheet(EvaluationSheet evalSheet, float value);
abstract int getMinValue(); abstract float getMinValue();
abstract int getMaxValue(); abstract float getMaxValue();
private void setText(float value) { private void setText(float value) {
txtView.setText(String.format(getFormat(), value)); txtView.setText(String.format(getFormat(), value));
@@ -175,12 +175,12 @@ class WeightMeasurement extends Measurement {
} }
@Override @Override
int getMinValue() { float getMinValue() {
return 30; return 30;
} }
@Override @Override
int getMaxValue() { float getMaxValue() {
return 300; return 300;
} }
} }
@@ -238,12 +238,12 @@ class BMIMeasurement extends Measurement {
} }
@Override @Override
int getMinValue() { float getMinValue() {
return 10; return 10;
} }
@Override @Override
int getMaxValue() { float getMaxValue() {
return 50; return 50;
} }
} }
@@ -300,12 +300,12 @@ class WaterMeasurement extends Measurement {
} }
@Override @Override
int getMinValue() { float getMinValue() {
return 30; return 30;
} }
@Override @Override
int getMaxValue() { float getMaxValue() {
return 80; return 80;
} }
} }
@@ -362,12 +362,12 @@ class MuscleMeasurement extends Measurement {
} }
@Override @Override
int getMinValue() { float getMinValue() {
return 10; return 10;
} }
@Override @Override
int getMaxValue() { float getMaxValue() {
return 80; return 80;
} }
} }
@@ -424,12 +424,12 @@ class FatMeasurement extends Measurement {
} }
@Override @Override
int getMinValue() { float getMinValue() {
return 10; return 10;
} }
@Override @Override
int getMaxValue() { float getMaxValue() {
return 40; return 40;
} }
} }
@@ -486,12 +486,12 @@ class WaistMeasurement extends Measurement {
} }
@Override @Override
int getMinValue() { float getMinValue() {
return 30; return 30;
} }
@Override @Override
int getMaxValue() { float getMaxValue() {
return 200; return 200;
} }
} }
@@ -548,12 +548,12 @@ class WHtRMeasurement extends Measurement {
} }
@Override @Override
int getMinValue() { float getMinValue() {
return 0; return 0;
} }
@Override @Override
int getMaxValue() { float getMaxValue() {
return 1; return 1;
} }
} }
@@ -610,12 +610,12 @@ class HipMeasurement extends Measurement {
} }
@Override @Override
int getMinValue() { float getMinValue() {
return 30; return 30;
} }
@Override @Override
int getMaxValue() { float getMaxValue() {
return 200; return 200;
} }
} }
@@ -672,13 +672,13 @@ class WHRMeasurement extends Measurement {
} }
@Override @Override
int getMinValue() { float getMinValue() {
return 0; return 0.5f;
} }
@Override @Override
int getMaxValue() { float getMaxValue() {
return 1; return 1.5f;
} }
} }