From 9b0c14c9c77947bebf8c975c1479799d3aec95de Mon Sep 17 00:00:00 2001 From: Jimmy Shih Date: Thu, 11 Jul 2013 09:51:54 -0700 Subject: [PATCH] In Stats view, only show speed and elevation when they are available. --- .../google/android/apps/mytracks/util/StatsUtils.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/MyTracks/src/com/google/android/apps/mytracks/util/StatsUtils.java b/MyTracks/src/com/google/android/apps/mytracks/util/StatsUtils.java index 2fc19c912..7d486c238 100644 --- a/MyTracks/src/com/google/android/apps/mytracks/util/StatsUtils.java +++ b/MyTracks/src/com/google/android/apps/mytracks/util/StatsUtils.java @@ -54,7 +54,8 @@ public class StatsUtils { activity, R.string.report_speed_key, PreferencesUtils.REPORT_SPEED_DEFAULT); // Set speed/pace - double speed = !isRecording || location == null ? Double.NaN : location.getSpeed(); + double speed = isRecording && location != null && location.hasSpeed() ? location.getSpeed() + : Double.NaN; setSpeed(activity, R.id.stats_speed, R.string.stats_speed, R.string.stats_pace, speed, metricUnits, reportSpeed); @@ -65,7 +66,8 @@ public class StatsUtils { View elevation = activity.findViewById(R.id.stats_elevation); if (showGradeElevation && isRecording) { - double altitude = location == null ? Double.NaN : location.getAltitude(); + double altitude = location != null && location.hasAltitude() ? location.getAltitude() + : Double.NaN; elevation.setVisibility(View.VISIBLE); setElevationValue(activity, R.id.stats_elevation, -1, altitude, metricUnits); } else { @@ -79,8 +81,8 @@ public class StatsUtils { View coordinateContainer = activity.findViewById(R.id.stats_coordinate_container); if (showCoordinate && isRecording) { - double latitude = location == null ? Double.NaN : location.getLatitude(); - double longitude = location == null ? Double.NaN : location.getLongitude(); + double latitude = location != null ? location.getLatitude() : Double.NaN; + double longitude = location != null ? location.getLongitude() : Double.NaN; coordinateHorizontalLine.setVisibility(View.VISIBLE); coordinateContainer.setVisibility(View.VISIBLE); setCoordinateValue(activity, R.id.stats_latitude, R.string.stats_latitude, latitude);