forked from upstream-mirrors/OpenTracks
Bugfix: CustomLayout - title for pace was speed/GPS.
Introduced in d70e7b8788
This commit is contained in:
@@ -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
|
@Override
|
||||||
public void onChanged(UnitSystem unitSystem, RecordingData data) {
|
public void onChanged(UnitSystem unitSystem, RecordingData data) {
|
||||||
// TODO Pace wont work for now
|
|
||||||
boolean reportSpeed = true;
|
|
||||||
SpeedFormatter localSpeedFormatter = SpeedFormatter.Builder()
|
SpeedFormatter localSpeedFormatter = SpeedFormatter.Builder()
|
||||||
.setUnit(unitSystem)
|
.setUnit(unitSystem)
|
||||||
.setReportSpeedOrPace(reportSpeed).build(getContext());
|
.setReportSpeedOrPace(reportSpeed)
|
||||||
|
.build(getContext());
|
||||||
|
|
||||||
Pair<String, String> valueAndUnit;
|
Pair<String, String> valueAndUnit;
|
||||||
|
|
||||||
@@ -85,7 +90,9 @@ public abstract class GenericStatisticsViewHolder extends StatisticViewHolder<St
|
|||||||
} else {
|
} else {
|
||||||
Speed speed = latestTrackPoint != null && latestTrackPoint.hasSpeed() ? latestTrackPoint.getSpeed() : null;
|
Speed speed = latestTrackPoint != null && latestTrackPoint.hasSpeed() ? latestTrackPoint.getSpeed() : null;
|
||||||
valueAndUnit = localSpeedFormatter.getSpeedParts(speed);
|
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);
|
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 {
|
public static class AverageMovingSpeed extends GenericStatisticsViewHolder {
|
||||||
|
|
||||||
@Override
|
@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_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_speed_key), GenericStatisticsViewHolder.SpeedVH::new);
|
||||||
m.put(context.getString(R.string.stats_custom_layout_pace_key), GenericStatisticsViewHolder.SpeedOrPace::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_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_average_speed_key), GenericStatisticsViewHolder.AverageSpeed::new);
|
||||||
m.put(context.getString(R.string.stats_custom_layout_max_speed_key), GenericStatisticsViewHolder.MaxSpeed::new);
|
m.put(context.getString(R.string.stats_custom_layout_max_speed_key), GenericStatisticsViewHolder.MaxSpeed::new);
|
||||||
|
|||||||
Reference in New Issue
Block a user