aboutsummaryrefslogtreecommitdiffstats
path: root/main/src/cgeo/geocaching/apps/cache/navi/AbstractPointNavigationApp.java
diff options
context:
space:
mode:
Diffstat (limited to 'main/src/cgeo/geocaching/apps/cache/navi/AbstractPointNavigationApp.java')
-rw-r--r--main/src/cgeo/geocaching/apps/cache/navi/AbstractPointNavigationApp.java56
1 files changed, 16 insertions, 40 deletions
diff --git a/main/src/cgeo/geocaching/apps/cache/navi/AbstractPointNavigationApp.java b/main/src/cgeo/geocaching/apps/cache/navi/AbstractPointNavigationApp.java
index 5817763..ca8c7db 100644
--- a/main/src/cgeo/geocaching/apps/cache/navi/AbstractPointNavigationApp.java
+++ b/main/src/cgeo/geocaching/apps/cache/navi/AbstractPointNavigationApp.java
@@ -2,14 +2,14 @@ package cgeo.geocaching.apps.cache.navi;
import cgeo.geocaching.cgCache;
import cgeo.geocaching.cgWaypoint;
-import cgeo.geocaching.geopoint.Geopoint;
+import cgeo.geocaching.apps.AbstractApp;
import android.app.Activity;
/**
* navigation app for simple point navigation (no differentiation between cache/waypoint/point)
*/
-abstract class AbstractPointNavigationApp extends AbstractNavigationApp {
+abstract class AbstractPointNavigationApp extends AbstractApp implements CacheNavigationApp, WaypointNavigationApp, GeopointNavigationApp {
protected AbstractPointNavigationApp(String name, String intent) {
super(name, intent);
@@ -20,46 +20,22 @@ abstract class AbstractPointNavigationApp extends AbstractNavigationApp {
}
@Override
- public final boolean invoke(Activity activity, cgCache cache, cgWaypoint waypoint, Geopoint coords) {
- if (cache == null && waypoint == null && coords == null) {
- return false;
- }
-
- try {
- if (isInstalled()) {
- final Geopoint point = getCoordinates(cache, waypoint, coords);
- if (point != null) {
- navigate(activity, point);
- return true;
- }
- }
- } catch (Exception e) {
- // nothing
- }
-
- return false;
+ public void navigate(Activity activity, cgCache cache) {
+ navigate(activity, cache.getCoords());
}
- protected abstract void navigate(Activity activity, Geopoint point);
-
- /**
- * Return the first of the cache coordinates, the waypoint coordinates or the extra coordinates. <code>null</code>
- * entities are skipped.
- *
- * @param cache a cache
- * @param waypoint a waypoint
- * @param coords extra coordinates
- * @return the first non-null coordinates, or null if none are set
- */
- private static Geopoint getCoordinates(final cgCache cache, final cgWaypoint waypoint, final Geopoint coords) {
- if (cache != null && cache.getCoords() != null) {
- return cache.getCoords();
- }
+ @Override
+ public void navigate(Activity activity, cgWaypoint waypoint) {
+ navigate(activity, waypoint.getCoords());
+ }
- if (waypoint != null && waypoint.getCoords() != null) {
- return waypoint.getCoords();
- }
+ @Override
+ public boolean isEnabled(cgCache cache) {
+ return cache.getCoords() != null;
+ }
- return coords;
+ @Override
+ public boolean isEnabled(cgWaypoint waypoint) {
+ return waypoint.getCoords() != null;
}
-} \ No newline at end of file
+}