Bugfix: CustomLayout - title for pace was speed/GPS.

Introduced in d70e7b8788
This commit is contained in:
Dennis Guse
2023-04-26 07:19:02 +02:00
parent 96fb65b6b0
commit 32dc6fef82
2 changed files with 28 additions and 7 deletions
@@ -65,15 +65,20 @@ public abstract class GenericStatisticsViewHolder extends StatisticViewHolder<St
}
}
public static class SpeedOrPace extends GenericStatisticsViewHolder {
public abstract static class SpeedOrPace extends GenericStatisticsViewHolder {
private final boolean reportSpeed;
public SpeedOrPace(boolean reportSpeed) {
this.reportSpeed = reportSpeed;
}
@Override
public void onChanged(UnitSystem unitSystem, RecordingData data) {
// TODO Pace wont work for now
boolean reportSpeed = true;
SpeedFormatter localSpeedFormatter = SpeedFormatter.Builder()
.setUnit(unitSystem)
.setReportSpeedOrPace(reportSpeed).build(getContext());
.setReportSpeedOrPace(reportSpeed)
.build(getContext());
Pair<String, String> valueAndUnit;
@@ -85,7 +90,9 @@ public abstract class GenericStatisticsViewHolder extends StatisticViewHolder<St
} else {
Speed speed = latestTrackPoint != null && latestTrackPoint.hasSpeed() ? latestTrackPoint.getSpeed() : null;
valueAndUnit = localSpeedFormatter.getSpeedParts(speed);
getBinding().statsDescriptionMain.setText(getContext().getString(R.string.description_speed_source_gps));
String title = reportSpeed ? getContext().getString(R.string.stats_speed) : getContext().getString(R.string.stats_pace);
getBinding().statsDescriptionMain.setText(title);
}
getBinding().statsValue.setText(valueAndUnit.first);
@@ -93,6 +100,20 @@ public abstract class GenericStatisticsViewHolder extends StatisticViewHolder<St
}
}
public static class SpeedVH extends SpeedOrPace {
public SpeedVH() {
super(true);
}
}
public static class PaceVH extends SpeedOrPace {
public PaceVH() {
super(false);
}
}
public static class AverageMovingSpeed extends GenericStatisticsViewHolder {
@Override
@@ -17,8 +17,8 @@ public class Mapping {
m.put(context.getString(R.string.stats_custom_layout_distance_key), GenericStatisticsViewHolder.Distance::new);
m.put(context.getString(R.string.stats_custom_layout_speed_key), GenericStatisticsViewHolder.SpeedOrPace::new);
m.put(context.getString(R.string.stats_custom_layout_pace_key), GenericStatisticsViewHolder.SpeedOrPace::new);
m.put(context.getString(R.string.stats_custom_layout_speed_key), GenericStatisticsViewHolder.SpeedVH::new);
m.put(context.getString(R.string.stats_custom_layout_pace_key), GenericStatisticsViewHolder.PaceVH::new);
m.put(context.getString(R.string.stats_custom_layout_average_moving_speed_key), GenericStatisticsViewHolder.AverageMovingSpeed::new);
m.put(context.getString(R.string.stats_custom_layout_average_speed_key), GenericStatisticsViewHolder.AverageSpeed::new);
m.put(context.getString(R.string.stats_custom_layout_max_speed_key), GenericStatisticsViewHolder.MaxSpeed::new);