diff options
author | Samuel Tardieu <sam@rfc1149.net> | 2012-04-27 12:10:34 +0200 |
---|---|---|
committer | Samuel Tardieu <sam@rfc1149.net> | 2012-04-27 12:10:34 +0200 |
commit | 5a10f40f72702009d2afc3bc6501b8843a70bb03 (patch) | |
tree | 95185ab6c5d83d53a461f1c9f57d6e892b9bcc0c /main/src/cgeo/geocaching/apps | |
parent | af61aa12c6b9e0adffc69bae94a0ae28f9c3db7b (diff) | |
download | cgeo-5a10f40f72702009d2afc3bc6501b8843a70bb03.zip cgeo-5a10f40f72702009d2afc3bc6501b8843a70bb03.tar.gz cgeo-5a10f40f72702009d2afc3bc6501b8843a70bb03.tar.bz2 |
Use the IGeoData interface and Observer pattern to update location
Diffstat (limited to 'main/src/cgeo/geocaching/apps')
13 files changed, 47 insertions, 50 deletions
diff --git a/main/src/cgeo/geocaching/apps/cache/navi/AbstractPointNavigationApp.java b/main/src/cgeo/geocaching/apps/cache/navi/AbstractPointNavigationApp.java index bf7ebb1..c5abf7f 100644 --- a/main/src/cgeo/geocaching/apps/cache/navi/AbstractPointNavigationApp.java +++ b/main/src/cgeo/geocaching/apps/cache/navi/AbstractPointNavigationApp.java @@ -1,7 +1,7 @@ package cgeo.geocaching.apps.cache.navi; +import cgeo.geocaching.IGeoData; import cgeo.geocaching.cgCache; -import cgeo.geocaching.cgGeo; import cgeo.geocaching.cgWaypoint; import cgeo.geocaching.geopoint.Geopoint; @@ -24,7 +24,7 @@ abstract class AbstractPointNavigationApp extends AbstractNavigationApp { } @Override - public final boolean invoke(cgGeo geo, Activity activity, cgCache cache, cgWaypoint waypoint, Geopoint coords) { + public final boolean invoke(IGeoData geo, Activity activity, cgCache cache, cgWaypoint waypoint, Geopoint coords) { if (cache == null && waypoint == null && coords == null) { return false; } diff --git a/main/src/cgeo/geocaching/apps/cache/navi/CompassApp.java b/main/src/cgeo/geocaching/apps/cache/navi/CompassApp.java index 3d804d9..720b85a 100644 --- a/main/src/cgeo/geocaching/apps/cache/navi/CompassApp.java +++ b/main/src/cgeo/geocaching/apps/cache/navi/CompassApp.java @@ -1,8 +1,8 @@ package cgeo.geocaching.apps.cache.navi; +import cgeo.geocaching.IGeoData; import cgeo.geocaching.R; import cgeo.geocaching.cgCache; -import cgeo.geocaching.cgGeo; import cgeo.geocaching.cgWaypoint; import cgeo.geocaching.cgeonavigate; import cgeo.geocaching.geopoint.Geopoint; @@ -22,7 +22,7 @@ class CompassApp extends AbstractNavigationApp { } @Override - public boolean invoke(cgGeo geo, Activity activity, cgCache cache, + public boolean invoke(IGeoData geo, Activity activity, cgCache cache, cgWaypoint waypoint, final Geopoint coords) { if (cache != null && cache.getGeocode() != null) { diff --git a/main/src/cgeo/geocaching/apps/cache/navi/GoogleNavigationApp.java b/main/src/cgeo/geocaching/apps/cache/navi/GoogleNavigationApp.java index 74141c3..e5001da 100644 --- a/main/src/cgeo/geocaching/apps/cache/navi/GoogleNavigationApp.java +++ b/main/src/cgeo/geocaching/apps/cache/navi/GoogleNavigationApp.java @@ -1,11 +1,11 @@ package cgeo.geocaching.apps.cache.navi; +import cgeo.geocaching.IGeoData; import cgeo.geocaching.R; import cgeo.geocaching.Settings; +import cgeo.geocaching.activity.ActivityMixin; import cgeo.geocaching.cgCache; -import cgeo.geocaching.cgGeo; import cgeo.geocaching.cgWaypoint; -import cgeo.geocaching.activity.ActivityMixin; import cgeo.geocaching.geopoint.Geopoint; import cgeo.geocaching.utils.Log; @@ -26,7 +26,7 @@ class GoogleNavigationApp extends AbstractNavigationApp { } @Override - public boolean invoke(final cgGeo geo, final Activity activity, final cgCache cache, final cgWaypoint waypoint, final Geopoint coords) { + public boolean invoke(final IGeoData geo, final Activity activity, final cgCache cache, final cgWaypoint waypoint, final Geopoint coords) { if (activity == null) { return false; } @@ -50,8 +50,8 @@ class GoogleNavigationApp extends AbstractNavigationApp { return true; } - private static boolean navigateToCoordinates(cgGeo geo, Activity activity, final Geopoint coords) { - final Geopoint coordsNow = geo == null ? null : geo.coordsNow; + private static boolean navigateToCoordinates(IGeoData geo, Activity activity, final Geopoint coords) { + final Geopoint coordsNow = geo == null ? null : geo.getCoordsNow(); // Google Navigation if (Settings.isUseGoogleNavigation()) { diff --git a/main/src/cgeo/geocaching/apps/cache/navi/InternalMap.java b/main/src/cgeo/geocaching/apps/cache/navi/InternalMap.java index 44f151e..2f05459 100644 --- a/main/src/cgeo/geocaching/apps/cache/navi/InternalMap.java +++ b/main/src/cgeo/geocaching/apps/cache/navi/InternalMap.java @@ -1,8 +1,8 @@ package cgeo.geocaching.apps.cache.navi; +import cgeo.geocaching.IGeoData; import cgeo.geocaching.R; import cgeo.geocaching.cgCache; -import cgeo.geocaching.cgGeo; import cgeo.geocaching.cgWaypoint; import cgeo.geocaching.enumerations.WaypointType; import cgeo.geocaching.geopoint.Geopoint; @@ -18,7 +18,7 @@ class InternalMap extends AbstractNavigationApp { } @Override - public boolean invoke(cgGeo geo, Activity activity, cgCache cache, + public boolean invoke(IGeoData geo, Activity activity, cgCache cache, cgWaypoint waypoint, final Geopoint coords) { if (cache != null) { CGeoMap.startActivityGeoCode(activity, cache.getGeocode()); diff --git a/main/src/cgeo/geocaching/apps/cache/navi/LocusApp.java b/main/src/cgeo/geocaching/apps/cache/navi/LocusApp.java index c867373..60e3315 100644 --- a/main/src/cgeo/geocaching/apps/cache/navi/LocusApp.java +++ b/main/src/cgeo/geocaching/apps/cache/navi/LocusApp.java @@ -1,9 +1,9 @@ package cgeo.geocaching.apps.cache.navi; +import cgeo.geocaching.IGeoData; +import cgeo.geocaching.apps.AbstractLocusApp; import cgeo.geocaching.cgCache; -import cgeo.geocaching.cgGeo; import cgeo.geocaching.cgWaypoint; -import cgeo.geocaching.apps.AbstractLocusApp; import cgeo.geocaching.geopoint.Geopoint; import android.app.Activity; @@ -20,7 +20,7 @@ class LocusApp extends AbstractLocusApp implements NavigationApp { * @author koem */ @Override - public boolean invoke(cgGeo geo, Activity activity, cgCache cache, cgWaypoint waypoint, final Geopoint coords) { + public boolean invoke(IGeoData geo, Activity activity, cgCache cache, cgWaypoint waypoint, final Geopoint coords) { final ArrayList<Object> points = new ArrayList<Object>(); diff --git a/main/src/cgeo/geocaching/apps/cache/navi/NavigationApp.java b/main/src/cgeo/geocaching/apps/cache/navi/NavigationApp.java index 119d27b..62629de 100644 --- a/main/src/cgeo/geocaching/apps/cache/navi/NavigationApp.java +++ b/main/src/cgeo/geocaching/apps/cache/navi/NavigationApp.java @@ -1,15 +1,15 @@ package cgeo.geocaching.apps.cache.navi; +import cgeo.geocaching.IGeoData; +import cgeo.geocaching.apps.App; import cgeo.geocaching.cgCache; -import cgeo.geocaching.cgGeo; import cgeo.geocaching.cgWaypoint; -import cgeo.geocaching.apps.App; import cgeo.geocaching.geopoint.Geopoint; import android.app.Activity; public interface NavigationApp extends App { - public boolean invoke(final cgGeo geo, final Activity activity, + public boolean invoke(final IGeoData geo, final Activity activity, final cgCache cache, final cgWaypoint waypoint, final Geopoint coords); } diff --git a/main/src/cgeo/geocaching/apps/cache/navi/NavigationAppFactory.java b/main/src/cgeo/geocaching/apps/cache/navi/NavigationAppFactory.java index 052189a..6f179ab 100644 --- a/main/src/cgeo/geocaching/apps/cache/navi/NavigationAppFactory.java +++ b/main/src/cgeo/geocaching/apps/cache/navi/NavigationAppFactory.java @@ -1,14 +1,13 @@ package cgeo.geocaching.apps.cache.navi; +import cgeo.geocaching.IGeoData; import cgeo.geocaching.R; -import cgeo.geocaching.SearchResult; import cgeo.geocaching.Settings; import cgeo.geocaching.StaticMapsProvider; +import cgeo.geocaching.apps.AbstractAppFactory; import cgeo.geocaching.cgCache; -import cgeo.geocaching.cgGeo; import cgeo.geocaching.cgWaypoint; import cgeo.geocaching.cgeoapplication; -import cgeo.geocaching.apps.AbstractAppFactory; import cgeo.geocaching.geopoint.Geopoint; import cgeo.geocaching.utils.Log; @@ -80,7 +79,7 @@ public final class NavigationAppFactory extends AbstractAppFactory { * A dialog is created for tool selection and the selected tool is started afterwards. * <p /> * Delegates to - * {@link #showNavigationMenu(cgGeo, Activity, cgCache, SearchResult, cgWaypoint, Geopoint, boolean, boolean)} with + * {@link #showNavigationMenu(IGeoData, Activity, cgCache, cgWaypoint, Geopoint, boolean, boolean)} with * <code>showInternalMap = true</code> and <code>showDefaultNavigation = false</code> * * @param geo @@ -89,7 +88,7 @@ public final class NavigationAppFactory extends AbstractAppFactory { * @param waypoint * @param destination */ - public static void showNavigationMenu(final cgGeo geo, final Activity activity, + public static void showNavigationMenu(final IGeoData geo, final Activity activity, final cgCache cache, final cgWaypoint waypoint, final Geopoint destination) { showNavigationMenu(geo, activity, cache, waypoint, destination, true, false); } @@ -111,9 +110,9 @@ public final class NavigationAppFactory extends AbstractAppFactory { * @param showDefaultNavigation * should be <code>false</code> by default * - * @see #showNavigationMenu(cgGeo, Activity, cgCache, cgWaypoint, Geopoint) + * @see #showNavigationMenu(IGeoData, Activity, cgCache, cgWaypoint, Geopoint) */ - public static void showNavigationMenu(final cgGeo geo, final Activity activity, + public static void showNavigationMenu(final IGeoData geo, final Activity activity, final cgCache cache, final cgWaypoint waypoint, final Geopoint destination, final boolean showInternalMap, final boolean showDefaultNavigation) { final AlertDialog.Builder builder = new AlertDialog.Builder(activity); @@ -188,10 +187,10 @@ public final class NavigationAppFactory extends AbstractAppFactory { /** * Adds the installed navigation tools to the given menu. - * Use {@link #onMenuItemSelected(MenuItem, cgGeo, Activity, cgCache, SearchResult, cgWaypoint, Geopoint)} on + * Use {@link #onMenuItemSelected(MenuItem, IGeoData, Activity, cgCache, cgWaypoint, Geopoint)} on * selection event to start the selected navigation tool. * - * <b>Only use this way if {@link #showNavigationMenu(cgGeo, Activity, cgCache, SearchResult, cgWaypoint, Geopoint)} + * <b>Only use this way if {@link #showNavigationMenu(IGeoData, Activity, cgCache, cgWaypoint, Geopoint)} * is not suitable for the given usecase.</b> * * @param menu @@ -203,11 +202,11 @@ public final class NavigationAppFactory extends AbstractAppFactory { /** * Adds the installed navigation tools to the given menu. - * Use {@link #onMenuItemSelected(MenuItem, cgGeo, Activity, cgCache, cgWaypoint, Geopoint)} on + * Use {@link #onMenuItemSelected(MenuItem, IGeoData, Activity, cgCache, cgWaypoint, Geopoint)} on * selection event to start the selected navigation tool. * * <b>Only use this way if - * {@link #showNavigationMenu(cgGeo, Activity, cgCache, cgWaypoint, Geopoint, boolean, boolean)} is + * {@link #showNavigationMenu(IGeoData, Activity, cgCache, cgWaypoint, Geopoint, boolean, boolean)} is * not suitable for the given usecase.</b> * * @param menu @@ -239,7 +238,7 @@ public final class NavigationAppFactory extends AbstractAppFactory { * @return */ public static boolean onMenuItemSelected(final MenuItem item, - final cgGeo geo, Activity activity, cgCache cache, cgWaypoint waypoint, final Geopoint destination) { + final IGeoData geo, Activity activity, cgCache cache, cgWaypoint waypoint, final Geopoint destination) { if (cache == null && waypoint == null && destination == null) { return false; } @@ -271,11 +270,10 @@ public final class NavigationAppFactory extends AbstractAppFactory { * @param geo * @param activity * @param cache - * @param search * @param waypoint * @param destination */ - public static void startDefaultNavigationApplication(final cgGeo geo, Activity activity, cgCache cache, + public static void startDefaultNavigationApplication(final IGeoData geo, Activity activity, cgCache cache, cgWaypoint waypoint, final Geopoint destination) { final NavigationApp app = getDefaultNavigationApplication(activity); @@ -294,11 +292,10 @@ public final class NavigationAppFactory extends AbstractAppFactory { * @param geo * @param activity * @param cache - * @param search * @param waypoint * @param destination */ - public static void startDefaultNavigationApplication2(final cgGeo geo, Activity activity, cgCache cache, + public static void startDefaultNavigationApplication2(final IGeoData geo, Activity activity, cgCache cache, cgWaypoint waypoint, final Geopoint destination) { final NavigationApp app = getDefaultNavigationApplication2(activity); diff --git a/main/src/cgeo/geocaching/apps/cache/navi/RMapsApp.java b/main/src/cgeo/geocaching/apps/cache/navi/RMapsApp.java index a87e61b..9af90ac 100644 --- a/main/src/cgeo/geocaching/apps/cache/navi/RMapsApp.java +++ b/main/src/cgeo/geocaching/apps/cache/navi/RMapsApp.java @@ -1,8 +1,8 @@ package cgeo.geocaching.apps.cache.navi; +import cgeo.geocaching.IGeoData; import cgeo.geocaching.R; import cgeo.geocaching.cgCache; -import cgeo.geocaching.cgGeo; import cgeo.geocaching.cgWaypoint; import cgeo.geocaching.geopoint.Geopoint; import cgeo.geocaching.geopoint.GeopointFormatter.Format; @@ -21,7 +21,7 @@ class RMapsApp extends AbstractNavigationApp { } @Override - public boolean invoke(cgGeo geo, Activity activity, cgCache cache, cgWaypoint waypoint, final Geopoint coords) { + public boolean invoke(IGeoData geo, Activity activity, cgCache cache, cgWaypoint waypoint, final Geopoint coords) { try { final ArrayList<String> locations = new ArrayList<String>(); if (cache != null && cache.getCoords() != null) { diff --git a/main/src/cgeo/geocaching/apps/cache/navi/StaticMapApp.java b/main/src/cgeo/geocaching/apps/cache/navi/StaticMapApp.java index db316bd..d8b66c2 100644 --- a/main/src/cgeo/geocaching/apps/cache/navi/StaticMapApp.java +++ b/main/src/cgeo/geocaching/apps/cache/navi/StaticMapApp.java @@ -1,12 +1,12 @@ package cgeo.geocaching.apps.cache.navi; +import cgeo.geocaching.IGeoData; import cgeo.geocaching.ILogable; import cgeo.geocaching.R; import cgeo.geocaching.StaticMapsActivity; +import cgeo.geocaching.activity.ActivityMixin; import cgeo.geocaching.cgCache; -import cgeo.geocaching.cgGeo; import cgeo.geocaching.cgWaypoint; -import cgeo.geocaching.activity.ActivityMixin; import cgeo.geocaching.geopoint.Geopoint; import android.app.Activity; @@ -25,7 +25,7 @@ class StaticMapApp extends AbstractNavigationApp { } @Override - public boolean invoke(cgGeo geo, Activity activity, cgCache cache, cgWaypoint waypoint, final Geopoint coords) { + public boolean invoke(IGeoData geo, Activity activity, cgCache cache, cgWaypoint waypoint, final Geopoint coords) { final ILogable logable = cache != null && cache.getListId() != 0 ? cache : waypoint; final String geocode = logable.getGeocode().toUpperCase(); if (geocode == null) { diff --git a/main/src/cgeo/geocaching/apps/cachelist/CacheListApp.java b/main/src/cgeo/geocaching/apps/cachelist/CacheListApp.java index 621aea4..45ebaff 100644 --- a/main/src/cgeo/geocaching/apps/cachelist/CacheListApp.java +++ b/main/src/cgeo/geocaching/apps/cachelist/CacheListApp.java @@ -1,9 +1,9 @@ package cgeo.geocaching.apps.cachelist; +import cgeo.geocaching.IGeoData; import cgeo.geocaching.SearchResult; -import cgeo.geocaching.cgCache; -import cgeo.geocaching.cgGeo; import cgeo.geocaching.apps.App; +import cgeo.geocaching.cgCache; import android.app.Activity; @@ -11,7 +11,7 @@ import java.util.List; interface CacheListApp extends App { - boolean invoke(final cgGeo geo, final List<cgCache> caches, + boolean invoke(final IGeoData geo, final List<cgCache> caches, final Activity activity, final SearchResult search); } diff --git a/main/src/cgeo/geocaching/apps/cachelist/CacheListAppFactory.java b/main/src/cgeo/geocaching/apps/cachelist/CacheListAppFactory.java index c8f201d..3c9d8df 100644 --- a/main/src/cgeo/geocaching/apps/cachelist/CacheListAppFactory.java +++ b/main/src/cgeo/geocaching/apps/cachelist/CacheListAppFactory.java @@ -1,11 +1,11 @@ package cgeo.geocaching.apps.cachelist; +import cgeo.geocaching.IGeoData; import cgeo.geocaching.R; import cgeo.geocaching.SearchResult; -import cgeo.geocaching.cgCache; -import cgeo.geocaching.cgGeo; import cgeo.geocaching.activity.IAbstractActivity; import cgeo.geocaching.apps.AbstractAppFactory; +import cgeo.geocaching.cgCache; import cgeo.geocaching.utils.Log; import org.apache.commons.lang3.ArrayUtils; @@ -63,7 +63,7 @@ public final class CacheListAppFactory extends AbstractAppFactory { } public static boolean onMenuItemSelected(final MenuItem item, - final cgGeo geo, final List<cgCache> caches, final IAbstractActivity activity, + final IGeoData geo, final List<cgCache> caches, final IAbstractActivity activity, final SearchResult search) { CacheListApp app = (CacheListApp) getAppFromMenuItem(item, apps); if (app != null) { diff --git a/main/src/cgeo/geocaching/apps/cachelist/InternalCacheListMap.java b/main/src/cgeo/geocaching/apps/cachelist/InternalCacheListMap.java index 5eaefc9..f450bbc 100644 --- a/main/src/cgeo/geocaching/apps/cachelist/InternalCacheListMap.java +++ b/main/src/cgeo/geocaching/apps/cachelist/InternalCacheListMap.java @@ -1,10 +1,10 @@ package cgeo.geocaching.apps.cachelist; +import cgeo.geocaching.IGeoData; import cgeo.geocaching.R; import cgeo.geocaching.SearchResult; -import cgeo.geocaching.cgCache; -import cgeo.geocaching.cgGeo; import cgeo.geocaching.apps.AbstractApp; +import cgeo.geocaching.cgCache; import cgeo.geocaching.maps.CGeoMap; import android.app.Activity; @@ -24,7 +24,7 @@ class InternalCacheListMap extends AbstractApp implements CacheListApp { } @Override - public boolean invoke(cgGeo geo, List<cgCache> caches, Activity activity, final SearchResult search) { + public boolean invoke(IGeoData geo, List<cgCache> caches, Activity activity, final SearchResult search) { CGeoMap.startActivitySearch(activity, search, null); return true; } diff --git a/main/src/cgeo/geocaching/apps/cachelist/LocusCacheListApp.java b/main/src/cgeo/geocaching/apps/cachelist/LocusCacheListApp.java index 1b50861..b7557c3 100644 --- a/main/src/cgeo/geocaching/apps/cachelist/LocusCacheListApp.java +++ b/main/src/cgeo/geocaching/apps/cachelist/LocusCacheListApp.java @@ -1,10 +1,10 @@ package cgeo.geocaching.apps.cachelist; +import cgeo.geocaching.IGeoData; import cgeo.geocaching.R; import cgeo.geocaching.SearchResult; -import cgeo.geocaching.cgCache; -import cgeo.geocaching.cgGeo; import cgeo.geocaching.apps.AbstractLocusApp; +import cgeo.geocaching.cgCache; import org.apache.commons.collections.CollectionUtils; @@ -29,7 +29,7 @@ class LocusCacheListApp extends AbstractLocusApp implements CacheListApp { * @author koem */ @Override - public boolean invoke(cgGeo geo, List<cgCache> cacheList, Activity activity, final SearchResult search) { + public boolean invoke(IGeoData geo, List<cgCache> cacheList, Activity activity, final SearchResult search) { if (CollectionUtils.isEmpty(cacheList)) { return false; } |