forked from upstream-mirrors/OpenTracks
fix comment for 5b638c36df7f
This commit is contained in:
@@ -45,9 +45,13 @@ public class AggregatedStatsActivity extends AbstractMyTracksActivity {
|
|||||||
boolean metricUnits = preferences.getBoolean(getString(R.string.metric_units_key), true);
|
boolean metricUnits = preferences.getBoolean(getString(R.string.metric_units_key), true);
|
||||||
boolean reportSpeed = preferences.getBoolean(getString(R.string.report_speed_key), true);
|
boolean reportSpeed = preferences.getBoolean(getString(R.string.report_speed_key), true);
|
||||||
|
|
||||||
StatsUtils.setSpeedLabels(this, reportSpeed, false);
|
StatsUtils.setStats(this,
|
||||||
StatsUtils.setTripStatisticsValues(this, getTripStatistics(), metricUnits, reportSpeed);
|
getTripStatistics(),
|
||||||
StatsUtils.setLocationElevationValue(this, Double.NaN, metricUnits);
|
null,
|
||||||
|
Double.NaN,
|
||||||
|
metricUnits,
|
||||||
|
reportSpeed,
|
||||||
|
false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -88,9 +88,13 @@ public class MarkerDetailActivity extends AbstractMyTracksActivity {
|
|||||||
boolean metricUnits = preferences.getBoolean(getString(R.string.metric_units_key), true);
|
boolean metricUnits = preferences.getBoolean(getString(R.string.metric_units_key), true);
|
||||||
boolean reportSpeed = preferences.getBoolean(getString(R.string.report_speed_key), true);
|
boolean reportSpeed = preferences.getBoolean(getString(R.string.report_speed_key), true);
|
||||||
|
|
||||||
StatsUtils.setSpeedLabels(this, reportSpeed, false);
|
StatsUtils.setStats(this,
|
||||||
StatsUtils.setTripStatisticsValues(this, waypoint.getStatistics(), metricUnits, reportSpeed);
|
waypoint.getStatistics(),
|
||||||
StatsUtils.setLocationElevationValue(this, waypoint.getLocation().getAltitude(), metricUnits);
|
null,
|
||||||
|
waypoint.getLocation().getAltitude(),
|
||||||
|
metricUnits,
|
||||||
|
reportSpeed,
|
||||||
|
false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -283,8 +283,12 @@ public class StatsFragment extends Fragment implements TrackDataListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void updateUi() {
|
private void updateUi() {
|
||||||
StatsUtils.setSpeedLabels(getActivity(), reportSpeed, true);
|
StatsUtils.setStats(getActivity(),
|
||||||
StatsUtils.setTripStatisticsValues(getActivity(), lastTripStatistics, metricUnits, reportSpeed);
|
lastTripStatistics,
|
||||||
StatsUtils.setLocationValues(getActivity(), lastLocation, metricUnits, reportSpeed);
|
lastLocation,
|
||||||
|
Double.NaN,
|
||||||
|
metricUnits,
|
||||||
|
reportSpeed,
|
||||||
|
true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,70 +33,31 @@ public class StatsUtils {
|
|||||||
private StatsUtils() {}
|
private StatsUtils() {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the speed labels.
|
* Sets stats.
|
||||||
*
|
|
||||||
* @param activity the activity
|
|
||||||
* @param reportSpeed true to report speed
|
|
||||||
* @param includeLocationSpeed true to include the current location speed
|
|
||||||
*/
|
|
||||||
public static void setSpeedLabels(
|
|
||||||
Activity activity, boolean reportSpeed, boolean includeLocationSpeed) {
|
|
||||||
StatsUtils.setSpeedLabel(activity, R.id.stats_max_speed_label, R.string.stats_max_speed,
|
|
||||||
R.string.stats_fastest_pace, reportSpeed);
|
|
||||||
StatsUtils.setSpeedLabel(activity, R.id.stats_average_speed_label, R.string.stats_average_speed,
|
|
||||||
R.string.stats_average_pace, reportSpeed);
|
|
||||||
StatsUtils.setSpeedLabel(activity, R.id.stats_average_moving_speed_label,
|
|
||||||
R.string.stats_average_moving_speed, R.string.stats_average_moving_pace, reportSpeed);
|
|
||||||
if (includeLocationSpeed) {
|
|
||||||
StatsUtils.setSpeedLabel(
|
|
||||||
activity, R.id.stats_speed_label, R.string.stats_speed, R.string.stats_pace, reportSpeed);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the trip statistics values.
|
|
||||||
*
|
*
|
||||||
* @param activity the activity
|
* @param activity the activity
|
||||||
* @param tripStatistics the trip statistics
|
* @param tripStatistics the trip statistics
|
||||||
|
* @param location the location, needed when showAll is true
|
||||||
|
* @param elevation the elevation, needed when showAll is false
|
||||||
* @param metricUnits true to display in metric units
|
* @param metricUnits true to display in metric units
|
||||||
* @param reportSpeed true to report speed
|
* @param reportSpeed true to report speed
|
||||||
|
* @param showAll true to display all fields
|
||||||
*/
|
*/
|
||||||
public static void setTripStatisticsValues(
|
public static void setStats(Activity activity,
|
||||||
Activity activity, TripStatistics tripStatistics, boolean metricUnits, boolean reportSpeed) {
|
TripStatistics tripStatistics,
|
||||||
double totalDistance = tripStatistics == null ? Double.NaN : tripStatistics.getTotalDistance();
|
Location location,
|
||||||
double maxSpeed = tripStatistics == null ? Double.NaN : tripStatistics.getMaxSpeed();
|
double elevation,
|
||||||
long totalTime = tripStatistics == null ? -1L : tripStatistics.getTotalTime();
|
boolean metricUnits,
|
||||||
double averageSpeed = tripStatistics == null ? Double.NaN : tripStatistics.getAverageSpeed();
|
boolean reportSpeed,
|
||||||
long movingTime = tripStatistics == null ? -1L : tripStatistics.getMovingTime();
|
boolean showAll) {
|
||||||
double averageMovingSpeed = tripStatistics == null ? Double.NaN
|
setSpeedLabels(activity, reportSpeed, showAll);
|
||||||
: tripStatistics.getAverageMovingSpeed();
|
setTripStatisticsValues(activity, tripStatistics, metricUnits, reportSpeed);
|
||||||
double elevationGain = tripStatistics == null ? Double.NaN
|
if (showAll) {
|
||||||
: tripStatistics.getTotalElevationGain();
|
setLocationValues(activity, location, metricUnits, reportSpeed);
|
||||||
double minElevation = tripStatistics == null ? Double.NaN : tripStatistics.getMinElevation();
|
} else {
|
||||||
double maxElevation = tripStatistics == null ? Double.NaN : tripStatistics.getMaxElevation();
|
setAltitudeValue(activity, R.id.stats_elevation_value, elevation, metricUnits);
|
||||||
double minGrade = tripStatistics == null ? Double.NaN : tripStatistics.getMinGrade();
|
}
|
||||||
double maxGrade = tripStatistics == null ? Double.NaN : tripStatistics.getMaxGrade();
|
|
||||||
|
|
||||||
StatsUtils.setDistanceValue(
|
|
||||||
activity, R.id.stats_total_distance_value, totalDistance, metricUnits);
|
|
||||||
StatsUtils.setSpeedValue(
|
|
||||||
activity, R.id.stats_max_speed_value, maxSpeed, metricUnits, reportSpeed);
|
|
||||||
StatsUtils.setTimeValue(activity, R.id.stats_total_time_value, totalTime);
|
|
||||||
StatsUtils.setSpeedValue(
|
|
||||||
activity, R.id.stats_average_speed_value, averageSpeed, metricUnits, reportSpeed);
|
|
||||||
StatsUtils.setTimeValue(activity, R.id.stats_moving_time_value, movingTime);
|
|
||||||
StatsUtils.setSpeedValue(activity, R.id.stats_average_moving_speed_value, averageMovingSpeed,
|
|
||||||
metricUnits, reportSpeed);
|
|
||||||
StatsUtils.setAltitudeValue(
|
|
||||||
activity, R.id.stats_elevation_gain_value, elevationGain, metricUnits);
|
|
||||||
StatsUtils.setAltitudeValue(
|
|
||||||
activity, R.id.stats_min_elevation_value, minElevation, metricUnits);
|
|
||||||
StatsUtils.setAltitudeValue(
|
|
||||||
activity, R.id.stats_max_elevation_value, maxElevation, metricUnits);
|
|
||||||
StatsUtils.setGradeValue(activity, R.id.stats_min_grade_value, minGrade);
|
|
||||||
StatsUtils.setGradeValue(activity, R.id.stats_max_grade_value, maxGrade);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the location values.
|
* Sets the location values.
|
||||||
*
|
*
|
||||||
@@ -112,22 +73,10 @@ public class StatsUtils {
|
|||||||
double latitude = location == null ? Double.NaN : location.getLatitude();
|
double latitude = location == null ? Double.NaN : location.getLatitude();
|
||||||
double longitude = location == null ? Double.NaN : location.getLongitude();
|
double longitude = location == null ? Double.NaN : location.getLongitude();
|
||||||
|
|
||||||
StatsUtils.setSpeedValue(activity, R.id.stats_speed_value, speed, metricUnits, reportSpeed);
|
setSpeedValue(activity, R.id.stats_speed_value, speed, metricUnits, reportSpeed);
|
||||||
StatsUtils.setAltitudeValue(activity, R.id.stats_elevation_value, altitude, metricUnits);
|
setAltitudeValue(activity, R.id.stats_elevation_value, altitude, metricUnits);
|
||||||
StatsUtils.setCoordinateValue(activity, R.id.stats_latitude_value, latitude);
|
setCoordinateValue(activity, R.id.stats_latitude_value, latitude);
|
||||||
StatsUtils.setCoordinateValue(activity, R.id.stats_longitude_value, longitude);
|
setCoordinateValue(activity, R.id.stats_longitude_value, longitude);
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the location elevation value.
|
|
||||||
*
|
|
||||||
* @param activity the activity
|
|
||||||
* @param elevation the elevation in meters
|
|
||||||
* @param metricUnits true to display in metric units
|
|
||||||
*/
|
|
||||||
public static void setLocationElevationValue(
|
|
||||||
Activity activity, double elevation, boolean metricUnits) {
|
|
||||||
StatsUtils.setAltitudeValue(activity, R.id.stats_elevation_value, elevation, metricUnits);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -137,7 +86,66 @@ public class StatsUtils {
|
|||||||
* @param totalTime the total time
|
* @param totalTime the total time
|
||||||
*/
|
*/
|
||||||
public static void setTotalTimeValue(Activity activity, long totalTime) {
|
public static void setTotalTimeValue(Activity activity, long totalTime) {
|
||||||
StatsUtils.setTimeValue(activity, R.id.stats_total_time_value, totalTime);
|
setTimeValue(activity, R.id.stats_total_time_value, totalTime);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the speed labels.
|
||||||
|
*
|
||||||
|
* @param activity the activity
|
||||||
|
* @param reportSpeed true to report speed
|
||||||
|
* @param includeLocationSpeed true to include the current location speed
|
||||||
|
*/
|
||||||
|
private static void setSpeedLabels(
|
||||||
|
Activity activity, boolean reportSpeed, boolean includeLocationSpeed) {
|
||||||
|
setSpeedLabel(activity, R.id.stats_max_speed_label, R.string.stats_max_speed,
|
||||||
|
R.string.stats_fastest_pace, reportSpeed);
|
||||||
|
setSpeedLabel(activity, R.id.stats_average_speed_label, R.string.stats_average_speed,
|
||||||
|
R.string.stats_average_pace, reportSpeed);
|
||||||
|
setSpeedLabel(activity, R.id.stats_average_moving_speed_label,
|
||||||
|
R.string.stats_average_moving_speed, R.string.stats_average_moving_pace, reportSpeed);
|
||||||
|
if (includeLocationSpeed) {
|
||||||
|
setSpeedLabel(
|
||||||
|
activity, R.id.stats_speed_label, R.string.stats_speed, R.string.stats_pace, reportSpeed);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the trip statistics values.
|
||||||
|
*
|
||||||
|
* @param activity the activity
|
||||||
|
* @param tripStatistics the trip statistics
|
||||||
|
* @param metricUnits true to display in metric units
|
||||||
|
* @param reportSpeed true to report speed
|
||||||
|
*/
|
||||||
|
private static void setTripStatisticsValues(
|
||||||
|
Activity activity, TripStatistics tripStatistics, boolean metricUnits, boolean reportSpeed) {
|
||||||
|
double totalDistance = tripStatistics == null ? Double.NaN : tripStatistics.getTotalDistance();
|
||||||
|
double maxSpeed = tripStatistics == null ? Double.NaN : tripStatistics.getMaxSpeed();
|
||||||
|
long totalTime = tripStatistics == null ? -1L : tripStatistics.getTotalTime();
|
||||||
|
double averageSpeed = tripStatistics == null ? Double.NaN : tripStatistics.getAverageSpeed();
|
||||||
|
long movingTime = tripStatistics == null ? -1L : tripStatistics.getMovingTime();
|
||||||
|
double averageMovingSpeed = tripStatistics == null ? Double.NaN
|
||||||
|
: tripStatistics.getAverageMovingSpeed();
|
||||||
|
double elevationGain = tripStatistics == null ? Double.NaN
|
||||||
|
: tripStatistics.getTotalElevationGain();
|
||||||
|
double minElevation = tripStatistics == null ? Double.NaN : tripStatistics.getMinElevation();
|
||||||
|
double maxElevation = tripStatistics == null ? Double.NaN : tripStatistics.getMaxElevation();
|
||||||
|
double minGrade = tripStatistics == null ? Double.NaN : tripStatistics.getMinGrade();
|
||||||
|
double maxGrade = tripStatistics == null ? Double.NaN : tripStatistics.getMaxGrade();
|
||||||
|
|
||||||
|
setDistanceValue(activity, R.id.stats_total_distance_value, totalDistance, metricUnits);
|
||||||
|
setSpeedValue(activity, R.id.stats_max_speed_value, maxSpeed, metricUnits, reportSpeed);
|
||||||
|
setTimeValue(activity, R.id.stats_total_time_value, totalTime);
|
||||||
|
setSpeedValue(activity, R.id.stats_average_speed_value, averageSpeed, metricUnits, reportSpeed);
|
||||||
|
setTimeValue(activity, R.id.stats_moving_time_value, movingTime);
|
||||||
|
setSpeedValue(activity, R.id.stats_average_moving_speed_value, averageMovingSpeed, metricUnits,
|
||||||
|
reportSpeed);
|
||||||
|
setAltitudeValue(activity, R.id.stats_elevation_gain_value, elevationGain, metricUnits);
|
||||||
|
setAltitudeValue(activity, R.id.stats_min_elevation_value, minElevation, metricUnits);
|
||||||
|
setAltitudeValue(activity, R.id.stats_max_elevation_value, maxElevation, metricUnits);
|
||||||
|
setGradeValue(activity, R.id.stats_min_grade_value, minGrade);
|
||||||
|
setGradeValue(activity, R.id.stats_max_grade_value, maxGrade);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user