Fix two bugs.

- reload waypoint in MarkerDetailActivity onResume
- In list item, if time/distance field is not available, use INVISIBLE rather than GONE.
This commit is contained in:
Jimmy Shih
2013-08-06 13:55:16 -07:00
parent 517b792e43
commit ba859b64e3
2 changed files with 18 additions and 7 deletions
@@ -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);
@@ -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);