diff --git a/MyTracks/src/com/google/android/apps/mytracks/AggregatedStatsActivity.java b/MyTracks/src/com/google/android/apps/mytracks/AggregatedStatsActivity.java index 10d1bbd39..d0ea24bc8 100644 --- a/MyTracks/src/com/google/android/apps/mytracks/AggregatedStatsActivity.java +++ b/MyTracks/src/com/google/android/apps/mytracks/AggregatedStatsActivity.java @@ -19,6 +19,7 @@ package com.google.android.apps.mytracks; import com.google.android.apps.mytracks.content.MyTracksProviderUtils; import com.google.android.apps.mytracks.content.Track; import com.google.android.apps.mytracks.stats.TripStatistics; +import com.google.android.apps.mytracks.util.CalorieUtils.ActivityType; import com.google.android.apps.mytracks.util.StatsUtils; import com.google.android.maps.mytracks.R; @@ -36,7 +37,8 @@ public class AggregatedStatsActivity extends AbstractMyTracksActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - StatsUtils.setTripStatisticsValues(this, this, null, getTripStatistics(), null); + StatsUtils.setTripStatisticsValues( + this, this, null, getTripStatistics(), ActivityType.WALKING, null); StatsUtils.setLocationValues(this, this, null, null, false); } diff --git a/MyTracks/src/com/google/android/apps/mytracks/fragments/MarkerDetailFragment.java b/MyTracks/src/com/google/android/apps/mytracks/fragments/MarkerDetailFragment.java index 3070bd105..8e02dafbd 100644 --- a/MyTracks/src/com/google/android/apps/mytracks/fragments/MarkerDetailFragment.java +++ b/MyTracks/src/com/google/android/apps/mytracks/fragments/MarkerDetailFragment.java @@ -22,6 +22,8 @@ import com.google.android.apps.mytracks.content.MyTracksProviderUtils; import com.google.android.apps.mytracks.content.Track; import com.google.android.apps.mytracks.content.Waypoint; import com.google.android.apps.mytracks.content.Waypoint.WaypointType; +import com.google.android.apps.mytracks.util.CalorieUtils; +import com.google.android.apps.mytracks.util.CalorieUtils.ActivityType; import com.google.android.apps.mytracks.util.IntentUtils; import com.google.android.apps.mytracks.util.PhotoUtils; import com.google.android.apps.mytracks.util.StatsUtils; @@ -279,8 +281,12 @@ public class MarkerDetailFragment extends Fragment { TextView name = (TextView) getView().findViewById(R.id.marker_detail_statistics_name); setTextView(name, waypoint.getName()); + Track track = myTracksProviderUtils.getTrack(waypoint.getTrackId()); + ActivityType activityType = track != null ? CalorieUtils.getActivityType( + getActivity(), track.getCategory()) + : ActivityType.INVALID; StatsUtils.setTripStatisticsValues( - getActivity(), null, getView(), waypoint.getTripStatistics(), null); + getActivity(), null, getView(), waypoint.getTripStatistics(), activityType, null); StatsUtils.setLocationValues(getActivity(), null, getView(), waypoint.getLocation(), false); } } diff --git a/MyTracks/src/com/google/android/apps/mytracks/fragments/StatsFragment.java b/MyTracks/src/com/google/android/apps/mytracks/fragments/StatsFragment.java index 871c2912d..e6493668d 100644 --- a/MyTracks/src/com/google/android/apps/mytracks/fragments/StatsFragment.java +++ b/MyTracks/src/com/google/android/apps/mytracks/fragments/StatsFragment.java @@ -23,6 +23,8 @@ import com.google.android.apps.mytracks.content.TrackDataListener; import com.google.android.apps.mytracks.content.TrackDataType; import com.google.android.apps.mytracks.content.Waypoint; import com.google.android.apps.mytracks.stats.TripStatistics; +import com.google.android.apps.mytracks.util.CalorieUtils; +import com.google.android.apps.mytracks.util.CalorieUtils.ActivityType; import com.google.android.apps.mytracks.util.LocationUtils; import com.google.android.apps.mytracks.util.PreferencesUtils; import com.google.android.apps.mytracks.util.StatsUtils; @@ -289,7 +291,10 @@ public class StatsFragment extends Fragment implements TrackDataListener { * Updates the UI. */ private void updateUi(FragmentActivity activity) { - StatsUtils.setTripStatisticsValues(activity, activity, null, lastTripStatistics, category); + ActivityType activityType = CalorieUtils.getActivityType(activity, category); + String trackIconValue = TrackIconUtils.getIconValue(activity, category); + StatsUtils.setTripStatisticsValues( + activity, activity, null, lastTripStatistics, activityType, trackIconValue); StatsUtils.setLocationValues( activity, activity, null, lastLocation, isSelectedTrackRecording()); } 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 d12d05f18..be0facd84 100644 --- a/MyTracks/src/com/google/android/apps/mytracks/util/StatsUtils.java +++ b/MyTracks/src/com/google/android/apps/mytracks/util/StatsUtils.java @@ -126,9 +126,12 @@ public class StatsUtils { * @param view the containing view for finding views. If null, the activity * cannot be null * @param tripStatistics the trip statistics + * @param activityType the activity type + * @param trackIconValue the track icon value or null to hide the track icon + * spinner */ - public static void setTripStatisticsValues( - Context context, Activity activity, View view, TripStatistics tripStatistics, String category) { + public static void setTripStatisticsValues(Context context, Activity activity, View view, + TripStatistics tripStatistics, ActivityType activityType, String trackIconValue) { boolean metricUnits = PreferencesUtils.isMetricUnits(context); boolean reportSpeed = PreferencesUtils.isReportSpeed(context); @@ -138,15 +141,14 @@ public class StatsUtils { context, getView(activity, view, R.id.stats_distance), totalDistance, metricUnits); // Set calorie - ActivityType activityType = CalorieUtils.getActivityType(context, category); double calorie = tripStatistics == null || activityType == ActivityType.INVALID ? Double.NaN : tripStatistics.getCalorie(); setCalorie(context, getView(activity, view, R.id.stats_calorie), calorie); Spinner spinner = (Spinner) getView(activity, view, R.id.stats_activity_type_icon); - spinner.setVisibility(category != null ? View.VISIBLE : View.GONE); - if (category != null) { - TrackIconUtils.setIconSpinner(spinner, TrackIconUtils.getIconValue(context, category)); + spinner.setVisibility(trackIconValue != null ? View.VISIBLE : View.GONE); + if (trackIconValue != null) { + TrackIconUtils.setIconSpinner(spinner, trackIconValue); } // Set total time diff --git a/MyTracks/src/com/google/android/apps/mytracks/util/TrackIconUtils.java b/MyTracks/src/com/google/android/apps/mytracks/util/TrackIconUtils.java index 6ab3b4bcb..d93640b49 100644 --- a/MyTracks/src/com/google/android/apps/mytracks/util/TrackIconUtils.java +++ b/MyTracks/src/com/google/android/apps/mytracks/util/TrackIconUtils.java @@ -142,6 +142,9 @@ public class TrackIconUtils { * @param activityType the activity type */ public static String getIconValue(Context context, String activityType) { + if (activityType == null || activityType.equals("")) { + return ""; + } if (inList(context, activityType, airplane)) { return AIRPLANE; }