From ba859b64e3c0fcd4326639d62fff9a3c405f62ba Mon Sep 17 00:00:00 2001 From: Jimmy Shih Date: Tue, 6 Aug 2013 13:55:16 -0700 Subject: [PATCH] Fix two bugs. - reload waypoint in MarkerDetailActivity onResume - In list item, if time/distance field is not available, use INVISIBLE rather than GONE. --- .../apps/mytracks/MarkerDetailActivity.java | 11 ++++++++++- .../android/apps/mytracks/util/ListItemUtils.java | 14 ++++++++------ 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/MyTracks/src/com/google/android/apps/mytracks/MarkerDetailActivity.java b/MyTracks/src/com/google/android/apps/mytracks/MarkerDetailActivity.java index f48afd85f..645bbb63b 100644 --- a/MyTracks/src/com/google/android/apps/mytracks/MarkerDetailActivity.java +++ b/MyTracks/src/com/google/android/apps/mytracks/MarkerDetailActivity.java @@ -73,7 +73,8 @@ public class MarkerDetailActivity extends AbstractMyTracksActivity implements De finish(); return; } - + + // Set waypoint, needed in onCreateOptionsMenu waypoint = myTracksProviderUtils.getWaypoint(markerId); if (waypoint == null) { Log.d(TAG, "waypoint is null"); @@ -95,6 +96,14 @@ public class MarkerDetailActivity extends AbstractMyTracksActivity implements De protected void onResume() { super.onResume(); + // Update waypoint in case it changed from an edit + waypoint = myTracksProviderUtils.getWaypoint(markerId); + if (waypoint == null) { + Log.d(TAG, "waypoint is null"); + finish(); + return; + } + name.setText(getString(R.string.generic_name_line, waypoint.getName())); if (waypoint.getType() == WaypointType.WAYPOINT) { waypointSection.setVisibility(View.VISIBLE); diff --git a/MyTracks/src/com/google/android/apps/mytracks/util/ListItemUtils.java b/MyTracks/src/com/google/android/apps/mytracks/util/ListItemUtils.java index 5f0f1c324..f34cd58e7 100644 --- a/MyTracks/src/com/google/android/apps/mytracks/util/ListItemUtils.java +++ b/MyTracks/src/com/google/android/apps/mytracks/util/ListItemUtils.java @@ -78,17 +78,18 @@ public class ListItemUtils { timeDistanceTextView.setTextAppearance(context, R.style.TextSmall); } setTextView(timeDistanceTextView, - getTimeDistance(context, isRecording, isPaused, sharedOwner, totalTime, totalDistance)); + getTimeDistance(context, isRecording, isPaused, sharedOwner, totalTime, totalDistance), + View.INVISIBLE); String[] startTimeDisplay = getStartTime(isRecording, context, startTime); TextView dateTextView = (TextView) view.findViewById(R.id.list_item_date); - setTextView(dateTextView, startTimeDisplay[0]); + setTextView(dateTextView, startTimeDisplay[0], View.GONE); TextView timeTextView = (TextView) view.findViewById(R.id.list_item_time); - setTextView(timeTextView, startTimeDisplay[1]); + setTextView(timeTextView, startTimeDisplay[1], View.GONE); TextView descriptionTextView = (TextView) view.findViewById(R.id.list_item_description); - setTextView(descriptionTextView, getDescription(isRecording, category, description)); + setTextView(descriptionTextView, getDescription(isRecording, category, description), View.GONE); } /** @@ -193,10 +194,11 @@ public class ListItemUtils { * * @param textView the text view * @param value the value for the text view + * @param visibility visibility when value is not available */ - private static void setTextView(TextView textView, String value) { + private static void setTextView(TextView textView, String value, int visibility) { if (value == null || value.length() == 0) { - textView.setVisibility(View.GONE); + textView.setVisibility(visibility); } else { textView.setVisibility(View.VISIBLE); textView.setText(value);