mirror of
https://github.com/oliexdev/openScale.git
synced 2025-09-03 13:23:24 +02:00
added min/max to statistic page
This commit is contained in:
@@ -81,10 +81,22 @@ class StatisticAdapter extends RecyclerView.Adapter<StatisticAdapter.ViewHolder>
|
|||||||
|
|
||||||
int i=0;
|
int i=0;
|
||||||
float sumValue = 0;
|
float sumValue = 0;
|
||||||
|
float maxValue = Float.MIN_VALUE;
|
||||||
|
float minValue = Float.MAX_VALUE;
|
||||||
for (ScaleMeasurement scaleMeasurement : scaleMeasurementList) {
|
for (ScaleMeasurement scaleMeasurement : scaleMeasurementList) {
|
||||||
measurementView.loadFrom(scaleMeasurement, null);
|
measurementView.loadFrom(scaleMeasurement, null);
|
||||||
sumValue += measurementView.getValue();
|
|
||||||
lineEntries.add(new Entry(i, measurementView.getValue()));
|
float value = measurementView.getValue();
|
||||||
|
|
||||||
|
sumValue += value;
|
||||||
|
if (value > maxValue) {
|
||||||
|
maxValue = value;
|
||||||
|
}
|
||||||
|
if (value < minValue) {
|
||||||
|
minValue = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
lineEntries.add(new Entry(i, value));
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -108,14 +120,19 @@ class StatisticAdapter extends RecyclerView.Adapter<StatisticAdapter.ViewHolder>
|
|||||||
measurementView.loadFrom(lastMeasurement, firstMeasurement);
|
measurementView.loadFrom(lastMeasurement, firstMeasurement);
|
||||||
|
|
||||||
holder.measurementName.setText(measurementView.getName());
|
holder.measurementName.setText(measurementView.getName());
|
||||||
SpannableStringBuilder diffValueText = new SpannableStringBuilder();
|
SpannableStringBuilder statisticValueText = new SpannableStringBuilder();
|
||||||
float avgValue = sumValue / scaleMeasurementList.size();
|
statisticValueText.append(activity.getResources().getString(R.string.label_abbr_min) + " " + measurementView.formatValue(minValue != Float.MAX_VALUE ? minValue : 0, true) + "\n");
|
||||||
diffValueText.append("(\u00d8 " + measurementView.formatValue(avgValue, true) + ") ");
|
statisticValueText.append(activity.getResources().getString(R.string.label_abbr_max) + " " + measurementView.formatValue(maxValue != Float.MIN_VALUE ? maxValue : 0, true) + "\n");
|
||||||
diffValueText.setSpan(new RelativeSizeSpan(0.8f), 0, diffValueText.length(),
|
statisticValueText.append(activity.getResources().getString(R.string.label_abbr_avg) + " " + measurementView.formatValue(sumValue != 0 ? sumValue / scaleMeasurementList.size() : 0, true) + "\n");
|
||||||
|
statisticValueText.setSpan(new RelativeSizeSpan(0.8f), 0, statisticValueText.length(),
|
||||||
Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
|
Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||||
measurementView.appendDiffValue(diffValueText, false);
|
|
||||||
holder.diffValueView.setText(diffValueText);
|
holder.statisticValueView.setText(statisticValueText);
|
||||||
holder.endValueView.setText(measurementView.getValueAsString(true));
|
SpannableStringBuilder endValueText = new SpannableStringBuilder();
|
||||||
|
measurementView.appendDiffValue(endValueText, true );
|
||||||
|
endValueText.append("\n");
|
||||||
|
endValueText.append(measurementView.getValueAsString(true));
|
||||||
|
holder.endValueView.setText(endValueText);
|
||||||
holder.iconView.setImageDrawable(measurementView.getIcon());
|
holder.iconView.setImageDrawable(measurementView.getIcon());
|
||||||
holder.iconView.setBackgroundTintList(ColorStateList.valueOf(measurementView.getColor()));
|
holder.iconView.setBackgroundTintList(ColorStateList.valueOf(measurementView.getColor()));
|
||||||
|
|
||||||
@@ -140,7 +157,7 @@ class StatisticAdapter extends RecyclerView.Adapter<StatisticAdapter.ViewHolder>
|
|||||||
|
|
||||||
static class ViewHolder extends RecyclerView.ViewHolder {
|
static class ViewHolder extends RecyclerView.ViewHolder {
|
||||||
TextView measurementName;
|
TextView measurementName;
|
||||||
TextView diffValueView;
|
TextView statisticValueView;
|
||||||
TextView startValueView;
|
TextView startValueView;
|
||||||
FloatingActionButton iconView;
|
FloatingActionButton iconView;
|
||||||
LineChart diffChartView;
|
LineChart diffChartView;
|
||||||
@@ -150,7 +167,7 @@ class StatisticAdapter extends RecyclerView.Adapter<StatisticAdapter.ViewHolder>
|
|||||||
super(itemView);
|
super(itemView);
|
||||||
|
|
||||||
measurementName = itemView.findViewById(R.id.measurementName);
|
measurementName = itemView.findViewById(R.id.measurementName);
|
||||||
diffValueView = itemView.findViewById(R.id.diffValueView);
|
statisticValueView = itemView.findViewById(R.id.statisticValueView);
|
||||||
startValueView = itemView.findViewById(R.id.startValueView);
|
startValueView = itemView.findViewById(R.id.startValueView);
|
||||||
iconView = itemView.findViewById(R.id.iconView);
|
iconView = itemView.findViewById(R.id.iconView);
|
||||||
diffChartView = itemView.findViewById(R.id.diffChartView);
|
diffChartView = itemView.findViewById(R.id.diffChartView);
|
||||||
|
@@ -27,12 +27,12 @@
|
|||||||
android:layout_marginStart="8dp"
|
android:layout_marginStart="8dp"
|
||||||
android:text="TextView"
|
android:text="TextView"
|
||||||
android:textStyle="bold"
|
android:textStyle="bold"
|
||||||
app:layout_constraintEnd_toStartOf="@+id/diffValueView"
|
app:layout_constraintEnd_toStartOf="@+id/statisticValueView"
|
||||||
app:layout_constraintStart_toEndOf="@+id/iconView"
|
app:layout_constraintStart_toEndOf="@+id/iconView"
|
||||||
app:layout_constraintTop_toTopOf="@+id/iconView" />
|
app:layout_constraintTop_toTopOf="@+id/iconView" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/diffValueView"
|
android:id="@+id/statisticValueView"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="TextView"
|
android:text="TextView"
|
||||||
@@ -69,7 +69,7 @@
|
|||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintEnd_toStartOf="@+id/endValueView"
|
app:layout_constraintEnd_toStartOf="@+id/endValueView"
|
||||||
app:layout_constraintStart_toEndOf="@+id/startValueView"
|
app:layout_constraintStart_toEndOf="@+id/startValueView"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/measurementName" />
|
app:layout_constraintTop_toBottomOf="@+id/statisticValueView" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/endValueView"
|
android:id="@+id/endValueView"
|
||||||
@@ -77,8 +77,7 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="TextView"
|
android:text="TextView"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent" />
|
||||||
app:layout_constraintTop_toTopOf="@+id/startValueView" />
|
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
|
||||||
|
@@ -60,6 +60,9 @@
|
|||||||
<string name="label_time_period_set_reference_day">set reference day</string>
|
<string name="label_time_period_set_reference_day">set reference day</string>
|
||||||
<string name="label_time_period_set_custom_range">set custom range</string>
|
<string name="label_time_period_set_custom_range">set custom range</string>
|
||||||
<string name="label_with">with</string>
|
<string name="label_with">with</string>
|
||||||
|
<string name="label_abbr_min">min</string>
|
||||||
|
<string name="label_abbr_max">max</string>
|
||||||
|
<string name="label_abbr_avg">avg</string>
|
||||||
<string name="label_birthday">Birthday</string>
|
<string name="label_birthday">Birthday</string>
|
||||||
<string name="label_user_name">Name</string>
|
<string name="label_user_name">Name</string>
|
||||||
<string name="label_height">Height</string>
|
<string name="label_height">Height</string>
|
||||||
|
Reference in New Issue
Block a user