diff options
| author | Karsten Priegnitz <koem@petoria.de> | 2011-09-11 08:45:51 +0200 |
|---|---|---|
| committer | Karsten Priegnitz <koem@petoria.de> | 2011-09-11 08:45:51 +0200 |
| commit | 7ea26b81f510300f7a321913189c2afe2749a275 (patch) | |
| tree | 0787a238854a49467a6a67863c0c0afe4767dd76 /src/cgeo/geocaching/apps | |
| parent | 7aed42d7b34d32e01e08799caf1ce0f4485fdf77 (diff) | |
| download | cgeo-7ea26b81f510300f7a321913189c2afe2749a275.zip cgeo-7ea26b81f510300f7a321913189c2afe2749a275.tar.gz cgeo-7ea26b81f510300f7a321913189c2afe2749a275.tar.bz2 | |
calling Locus - dates and empty waypoints
Diffstat (limited to 'src/cgeo/geocaching/apps')
| -rw-r--r-- | src/cgeo/geocaching/apps/AbstractLocusApp.java | 22 | ||||
| -rw-r--r-- | src/cgeo/geocaching/apps/cachelist/CacheListAppFactory.java | 3 |
2 files changed, 13 insertions, 12 deletions
diff --git a/src/cgeo/geocaching/apps/AbstractLocusApp.java b/src/cgeo/geocaching/apps/AbstractLocusApp.java index 31ae291..963a5e5 100644 --- a/src/cgeo/geocaching/apps/AbstractLocusApp.java +++ b/src/cgeo/geocaching/apps/AbstractLocusApp.java @@ -1,5 +1,6 @@ package cgeo.geocaching.apps; +import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.List; @@ -15,7 +16,6 @@ import android.content.Intent; import android.content.res.Resources; import android.location.Location; import cgeo.geocaching.R; -import cgeo.geocaching.cgBase; import cgeo.geocaching.cgCache; import cgeo.geocaching.cgSettings; import cgeo.geocaching.cgWaypoint; @@ -24,6 +24,7 @@ import cgeo.geocaching.enumerations.CacheType; public abstract class AbstractLocusApp extends AbstractApp { private static final String INTENT = Intent.ACTION_VIEW; + private static final SimpleDateFormat ISO8601DATE = new SimpleDateFormat("yyyy-MM-dd'T'"); protected AbstractLocusApp(final Resources res) { super(res.getString(R.string.caches_map_locus), INTENT); @@ -42,7 +43,7 @@ public abstract class AbstractLocusApp extends AbstractApp { * @author koem */ protected void showInLocus(List<? extends Object> objectsToShow, Activity activity) { - if (objectsToShow == null || activity == null) return; + if (objectsToShow == null) return; int pc = 0; // counter for points PointsData pd = new PointsData("c:geo"); @@ -50,11 +51,9 @@ public abstract class AbstractLocusApp extends AbstractApp { // get icon and Point Point p = null; if (o instanceof cgCache) { - cgCache c = (cgCache) o; - p = this.getPoint(c, activity); + p = this.getPoint((cgCache) o); } else if (o instanceof cgWaypoint) { - cgWaypoint w = (cgWaypoint) o; - p = this.getPoint(w); + p = this.getPoint((cgWaypoint) o); } else { continue; // no cache, no waypoint => ignore } @@ -82,7 +81,7 @@ public abstract class AbstractLocusApp extends AbstractApp { * @return null, when the <code>Point</code> could not be constructed * @author koem */ - private Point getPoint(cgCache cache, Context context) { + private Point getPoint(cgCache cache) { if (cache == null) return null; // create one simple point with location @@ -93,14 +92,15 @@ public abstract class AbstractLocusApp extends AbstractApp { Point p = new Point(cache.name, loc); PointGeocachingData pg = new PointGeocachingData(); p.setGeocachingData(pg); - + + // set data in Locus' cache pg.cacheID = cache.geocode; pg.available = ! cache.disabled; pg.archived = cache.archived; pg.premiumOnly = cache.members; pg.name = cache.name; pg.placedBy = cache.owner; - if (cache.hidden != null) pg.hidden = cgBase.formatFullDate(context, cache.hidden.getTime()); + if (cache.hidden != null) pg.hidden = ISO8601DATE.format(cache.hidden.getTime()); for (CacheType ct : CacheType.values()) { if (ct.cgeoId.equals(cache.type)) { if (ct.locusId != CacheType.NO_LOCUS_ID) pg.type = ct.locusId; @@ -121,7 +121,9 @@ public abstract class AbstractLocusApp extends AbstractApp { if (cache.waypoints != null) { pg.waypoints = new ArrayList<PointGeocachingDataWaypoint>(); for (cgWaypoint waypoint : cache.waypoints) { - if (waypoint == null) continue; + if (waypoint == null || waypoint.latitude == null || waypoint.longitude == null) { + continue; + } PointGeocachingDataWaypoint w = new PointGeocachingDataWaypoint(); w.code = waypoint.geocode; w.name = waypoint.name; diff --git a/src/cgeo/geocaching/apps/cachelist/CacheListAppFactory.java b/src/cgeo/geocaching/apps/cachelist/CacheListAppFactory.java index cb69e17..91e547a 100644 --- a/src/cgeo/geocaching/apps/cachelist/CacheListAppFactory.java +++ b/src/cgeo/geocaching/apps/cachelist/CacheListAppFactory.java @@ -64,8 +64,7 @@ public final class CacheListAppFactory extends AbstractAppFactory { public static boolean onMenuItemSelected(final MenuItem item, final cgGeo geo, final List<cgCache> caches, final Activity activity, final Resources res, final UUID searchId) { - CacheListApp app = (CacheListApp) getAppFromMenuItem( - item, apps); + CacheListApp app = (CacheListApp) getAppFromMenuItem(item, apps); if (app != null) { try { return app.invoke(geo, caches, activity, res, searchId); |
