After MapFragment is created, update the menu so

satellite versus map is shown correctly.
This commit is contained in:
Jimmy Shih
2012-06-22 13:08:08 -07:00
parent c885e9d0dd
commit ba17b37e50
4 changed files with 24 additions and 5 deletions
@@ -27,6 +27,7 @@ import com.google.android.apps.mytracks.content.TrackDataHub.ListenerDataType;
import com.google.android.apps.mytracks.content.TrackDataListener; import com.google.android.apps.mytracks.content.TrackDataListener;
import com.google.android.apps.mytracks.content.Waypoint; import com.google.android.apps.mytracks.content.Waypoint;
import com.google.android.apps.mytracks.stats.TripStatistics; import com.google.android.apps.mytracks.stats.TripStatistics;
import com.google.android.apps.mytracks.util.ApiAdapterFactory;
import com.google.android.apps.mytracks.util.GeoRect; import com.google.android.apps.mytracks.util.GeoRect;
import com.google.android.apps.mytracks.util.LocationUtils; import com.google.android.apps.mytracks.util.LocationUtils;
import com.google.android.maps.GeoPoint; import com.google.android.maps.GeoPoint;
@@ -120,6 +121,7 @@ public class MapFragment extends Fragment
}); });
messageTextView = (TextView) mapViewContainer.findViewById(R.id.map_message); messageTextView = (TextView) mapViewContainer.findViewById(R.id.map_message);
ApiAdapterFactory.getApiAdapter().invalidMenu(getActivity());
return mapViewContainer; return mapViewContainer;
} }
@@ -114,4 +114,9 @@ public class Api11Adapter extends Api10Adapter {
public <T> void addAllToArrayAdapter(ArrayAdapter<T> arrayAdapter, List<T> items) { public <T> void addAllToArrayAdapter(ArrayAdapter<T> arrayAdapter, List<T> items) {
arrayAdapter.addAll(items); arrayAdapter.addAll(items);
} }
@Override
public void invalidMenu(Activity activity) {
activity.invalidateOptionsMenu();
}
} }
@@ -146,6 +146,11 @@ public class Api7Adapter implements ApiAdapter {
} }
} }
@Override
public void invalidMenu(Activity activity) {
// Do nothing
}
@Override @Override
public boolean handleSearchKey(MenuItem menuItem) { public boolean handleSearchKey(MenuItem menuItem) {
// Return false and allow the framework to handle the search key. // Return false and allow the framework to handle the search key.
@@ -149,7 +149,7 @@ public interface ApiAdapter {
/** /**
* Configures the search widget. * Configures the search widget.
* * <p>
* Due to changes in API level 11. * Due to changes in API level 11.
* *
* @param activity the activity * @param activity the activity
@@ -159,7 +159,7 @@ public interface ApiAdapter {
/** /**
* Handles the search menu selection. Returns true if handled. * Handles the search menu selection. Returns true if handled.
* * <p>
* Due to changes in API level 11. * Due to changes in API level 11.
* *
* @param activity the activity * @param activity the activity
@@ -168,17 +168,24 @@ public interface ApiAdapter {
/** /**
* Adds all items to an array adapter. * Adds all items to an array adapter.
* * <p>
* Due to changes in API level 11. * Due to changes in API level 11.
*s *
* @param arrayAdapter the array adapter * @param arrayAdapter the array adapter
* @param items list of items * @param items list of items
*/ */
public <T> void addAllToArrayAdapter(ArrayAdapter<T> arrayAdapter, List<T> items); public <T> void addAllToArrayAdapter(ArrayAdapter<T> arrayAdapter, List<T> items);
/**
* Invalidates the menu.
* <p>
* Due to changes in API level 11.
*/
public void invalidMenu(Activity activity);
/** /**
* Handles the search key press. Returns true if handled. * Handles the search key press. Returns true if handled.
* * <p>
* Due to changes in API level 14. * Due to changes in API level 14.
* *
* @param menu the search menu * @param menu the search menu