diff options
author | Heiko W. Rupp <hwr@pilhuhn.de> | 2012-09-09 22:44:38 +0200 |
---|---|---|
committer | Heiko W. Rupp <hwr@pilhuhn.de> | 2012-09-09 22:44:38 +0200 |
commit | 760a91b383d7e40f1990c8ba82b65d5d42cea179 (patch) | |
tree | 4ae6ee9248e7f13cac66581b697efaf65456acdb /main/src/cgeo/geocaching/apps/cache | |
parent | 70bacd6a868db73d9a8cef23fe1885b5b147e991 (diff) | |
download | cgeo-760a91b383d7e40f1990c8ba82b65d5d42cea179.zip cgeo-760a91b383d7e40f1990c8ba82b65d5d42cea179.tar.gz cgeo-760a91b383d7e40f1990c8ba82b65d5d42cea179.tar.bz2 |
Prevent a NPE if cache and waypoint are null.
Diffstat (limited to 'main/src/cgeo/geocaching/apps/cache')
-rw-r--r-- | main/src/cgeo/geocaching/apps/cache/navi/AbstractStaticMapsApp.java | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/main/src/cgeo/geocaching/apps/cache/navi/AbstractStaticMapsApp.java b/main/src/cgeo/geocaching/apps/cache/navi/AbstractStaticMapsApp.java index 7530422..f27b53c 100644 --- a/main/src/cgeo/geocaching/apps/cache/navi/AbstractStaticMapsApp.java +++ b/main/src/cgeo/geocaching/apps/cache/navi/AbstractStaticMapsApp.java @@ -30,6 +30,8 @@ abstract class AbstractStaticMapsApp extends AbstractApp implements CacheNavigat } protected static boolean hasStaticMap(cgWaypoint waypoint) { + if (waypoint==null) + return false; String geocode = waypoint.getGeocode(); int id = waypoint.getId(); if (StringUtils.isNotEmpty(geocode) && cgeoapplication.getInstance().isOffline(geocode, null)) { @@ -40,11 +42,12 @@ abstract class AbstractStaticMapsApp extends AbstractApp implements CacheNavigat protected static boolean invokeStaticMaps(final Activity activity, final cgCache cache, final cgWaypoint waypoint, final boolean download) { final ILogable logable = cache != null && cache.getListId() != 0 ? cache : waypoint; - final String geocode = StringUtils.upperCase(logable.getGeocode()); - if (geocode == null) { + // If the cache is not stored for offline, cache seems to be null and waypoint may be null too + if (logable==null || logable.getGeocode()==null ) { ActivityMixin.showToast(activity, getString(R.string.err_detail_no_map_static)); return true; } + final String geocode = StringUtils.upperCase(logable.getGeocode()); StaticMapsActivity.startActivity(activity, geocode, download, waypoint); return true; |