diff options
| author | Bananeweizen <bananeweizen@gmx.de> | 2011-07-31 14:25:38 +0200 |
|---|---|---|
| committer | Bananeweizen <bananeweizen@gmx.de> | 2011-07-31 14:25:38 +0200 |
| commit | e085709cc8a8271b35da174e60586fa8ed23d77a (patch) | |
| tree | 82a766936f9ca08b0b918696e28fc8535c9e77d8 /src/cgeo/geocaching/apps | |
| parent | 9a4fa0f9305867a80e2d72a335ccd9078a2e72a7 (diff) | |
| download | cgeo-e085709cc8a8271b35da174e60586fa8ed23d77a.zip cgeo-e085709cc8a8271b35da174e60586fa8ed23d77a.tar.gz cgeo-e085709cc8a8271b35da174e60586fa8ed23d77a.tar.bz2 | |
* fix NullPointerException in filter context menu
* avoid NullPointerException in filter evaluation
* remove all hardcoded menu ids in cache list, there where overlaps
already
Diffstat (limited to 'src/cgeo/geocaching/apps')
| -rw-r--r-- | src/cgeo/geocaching/apps/cachelist/CacheListAppFactory.java | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/cgeo/geocaching/apps/cachelist/CacheListAppFactory.java b/src/cgeo/geocaching/apps/cachelist/CacheListAppFactory.java index 68d2b2b..1f80e77 100644 --- a/src/cgeo/geocaching/apps/cachelist/CacheListAppFactory.java +++ b/src/cgeo/geocaching/apps/cachelist/CacheListAppFactory.java @@ -7,6 +7,7 @@ import android.app.Activity; import android.content.res.Resources; import android.view.Menu; import android.view.MenuItem; +import android.view.SubMenu; import cgeo.geocaching.R; import cgeo.geocaching.cgCache; import cgeo.geocaching.cgGeo; @@ -27,7 +28,13 @@ public final class CacheListAppFactory extends AbstractAppFactory { return apps; } - public static void addMenuItems(Menu menu, + /** + * @param menu + * @param activity + * @param res + * @return the added menu item (also for a sub menu, then the menu item in the parent menu is returned) + */ + public static MenuItem addMenuItems(Menu menu, Activity activity, Resources res) { ArrayList<CacheListApp> activeApps = new ArrayList<CacheListApp>(); for (CacheListApp app : getMultiPointNavigationApps(res)) { @@ -37,16 +44,18 @@ public final class CacheListAppFactory extends AbstractAppFactory { } // use a new sub menu, if more than one app is available if (activeApps.size() > 1) { - Menu subMenu = menu.addSubMenu(0, 101, 0, + SubMenu subMenu = menu.addSubMenu(0, 101, 0, res.getString(R.string.caches_on_map)).setIcon( android.R.drawable.ic_menu_mapmode); for (CacheListApp app : activeApps) { subMenu.add(0, app.getId(), 0, app.getName()); } + return subMenu.getItem(); } else if (activeApps.size() == 1) { - menu.add(0, activeApps.get(0).getId(), 0, + return menu.add(0, activeApps.get(0).getId(), 0, activeApps.get(0).getName()).setIcon(android.R.drawable.ic_menu_mapmode); } + return null; } public static boolean onMenuItemSelected(final MenuItem item, |
