aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBananeweizen <bananeweizen@gmx.de>2011-09-15 07:15:24 +0200
committerBananeweizen <bananeweizen@gmx.de>2011-09-15 07:15:24 +0200
commitf632b993ea19b264746b802e5256e536b5c30d72 (patch)
tree86c454f8ca25890a929b13bd4f9fd0073b0a936b
parente997dd7707116acacda9c31424048f3b9f5500f9 (diff)
downloadcgeo-f632b993ea19b264746b802e5256e536b5c30d72.zip
cgeo-f632b993ea19b264746b802e5256e536b5c30d72.tar.gz
cgeo-f632b993ea19b264746b802e5256e536b5c30d72.tar.bz2
refactoring: code cleanup in maps apps support
-rw-r--r--src/cgeo/geocaching/apps/AbstractLocusApp.java33
-rw-r--r--src/cgeo/geocaching/apps/LocusDataStorageProvider.java3
-rw-r--r--src/cgeo/geocaching/apps/cache/navi/GoogleMapsApp.java4
-rw-r--r--src/cgeo/geocaching/apps/cache/navi/RMapsApp.java5
-rw-r--r--src/cgeo/geocaching/apps/cache/navi/RadarApp.java22
-rw-r--r--src/cgeo/geocaching/apps/cache/navi/StreetviewApp.java4
6 files changed, 39 insertions, 32 deletions
diff --git a/src/cgeo/geocaching/apps/AbstractLocusApp.java b/src/cgeo/geocaching/apps/AbstractLocusApp.java
index 453a1ba..f57987a 100644
--- a/src/cgeo/geocaching/apps/AbstractLocusApp.java
+++ b/src/cgeo/geocaching/apps/AbstractLocusApp.java
@@ -55,8 +55,9 @@ public abstract class AbstractLocusApp extends AbstractApp {
*/
protected void showInLocus(List<? extends Object> objectsToShow, boolean withCacheWaypoints,
Activity activity) {
- if (objectsToShow == null)
+ if (objectsToShow == null) {
return;
+ }
int pc = 0; // counter for points
PointsData pd = new PointsData("c:geo");
@@ -70,8 +71,9 @@ public abstract class AbstractLocusApp extends AbstractApp {
} else {
continue; // no cache, no waypoint => ignore
}
- if (p == null)
+ if (p == null) {
continue;
+ }
pd.addPoint(p);
++pc;
@@ -98,8 +100,9 @@ public abstract class AbstractLocusApp extends AbstractApp {
* @author koem
*/
private static Point getPoint(cgCache cache, boolean withWaypoints) {
- if (cache == null || cache.coords == null)
+ if (cache == null || cache.coords == null) {
return null;
+ }
// create one simple point with location
Location loc = new Location(cgSettings.tag);
@@ -117,31 +120,38 @@ public abstract class AbstractLocusApp extends AbstractApp {
pg.premiumOnly = cache.members;
pg.name = cache.name;
pg.placedBy = cache.owner;
- if (cache.hidden != null)
+ if (cache.hidden != null) {
pg.hidden = ISO8601DATE.format(cache.hidden.getTime());
+ }
int locusId = toLocusId(CacheType.FIND_BY_CGEOID.get(cache.type));
- if (locusId != NO_LOCUS_ID)
+ if (locusId != NO_LOCUS_ID) {
pg.type = locusId;
+ }
locusId = toLocusId(CacheSize.FIND_BY_CGEOID.get(cache.size));
- if (locusId != NO_LOCUS_ID)
+ if (locusId != NO_LOCUS_ID) {
pg.container = locusId;
- if (cache.difficulty != null)
+ }
+ if (cache.difficulty != null) {
pg.difficulty = cache.difficulty;
- if (cache.terrain != null)
+ }
+ if (cache.terrain != null) {
pg.terrain = cache.terrain;
+ }
pg.found = cache.found;
if (withWaypoints && cache.waypoints != null) {
pg.waypoints = new ArrayList<PointGeocachingDataWaypoint>();
for (cgWaypoint waypoint : cache.waypoints) {
- if (waypoint == null || waypoint.coords == null)
+ if (waypoint == null || waypoint.coords == null) {
continue;
+ }
PointGeocachingDataWaypoint wp = new PointGeocachingDataWaypoint();
wp.code = waypoint.geocode;
wp.name = waypoint.name;
String locusWpId = toLocusId(WaypointType.FIND_BY_CGEOID.get(waypoint.type));
- if (locusWpId != null)
+ if (locusWpId != null) {
wp.type = locusWpId;
+ }
wp.lat = waypoint.coords.getLatitude();
wp.lon = waypoint.coords.getLongitude();
pg.waypoints.add(wp);
@@ -168,8 +178,9 @@ public abstract class AbstractLocusApp extends AbstractApp {
* @author koem
*/
private static Point getPoint(cgWaypoint waypoint) {
- if (waypoint == null || waypoint.coords == null)
+ if (waypoint == null || waypoint.coords == null) {
return null;
+ }
// create one simple point with location
Location loc = new Location(cgSettings.tag);
diff --git a/src/cgeo/geocaching/apps/LocusDataStorageProvider.java b/src/cgeo/geocaching/apps/LocusDataStorageProvider.java
index fcc4ba2..69a5e5b 100644
--- a/src/cgeo/geocaching/apps/LocusDataStorageProvider.java
+++ b/src/cgeo/geocaching/apps/LocusDataStorageProvider.java
@@ -24,8 +24,9 @@ public class LocusDataStorageProvider extends ContentProvider {
DataCursor cursor = new DataCursor(new String[] { "data" });
ArrayList<PointsData> data = DataStorage.getData();
- if (data == null || data.size() == 0)
+ if (data == null || data.size() == 0) {
return cursor;
+ }
for (int i = 0; i < data.size(); i++) {
// get byte array
diff --git a/src/cgeo/geocaching/apps/cache/navi/GoogleMapsApp.java b/src/cgeo/geocaching/apps/cache/navi/GoogleMapsApp.java
index fd9caec..b60a635 100644
--- a/src/cgeo/geocaching/apps/cache/navi/GoogleMapsApp.java
+++ b/src/cgeo/geocaching/apps/cache/navi/GoogleMapsApp.java
@@ -40,6 +40,8 @@ class GoogleMapsApp extends AbstractNavigationApp implements NavigationApp {
startActivity(activity, cache.coords);
} else if (waypoint != null && waypoint.coords != null) {
startActivity(activity, waypoint.coords);
+ } else if (coords != null) {
+ startActivity(activity, coords);
}
return true;
@@ -56,7 +58,7 @@ class GoogleMapsApp extends AbstractNavigationApp implements NavigationApp {
return false;
}
- private void startActivity(Activity activity, final Geopoint coords) {
+ private static void startActivity(Activity activity, final Geopoint coords) {
activity.startActivity(new Intent(Intent.ACTION_VIEW,
Uri.parse("geo:" + coords.getLatitude() + "," + coords.getLongitude())));
// INFO: q parameter works with Google Maps, but breaks cooperation with all other apps
diff --git a/src/cgeo/geocaching/apps/cache/navi/RMapsApp.java b/src/cgeo/geocaching/apps/cache/navi/RMapsApp.java
index 24263e2..2d27493 100644
--- a/src/cgeo/geocaching/apps/cache/navi/RMapsApp.java
+++ b/src/cgeo/geocaching/apps/cache/navi/RMapsApp.java
@@ -53,11 +53,8 @@ class RMapsApp extends AbstractNavigationApp implements NavigationApp {
+ ";" + waypoint.name);
}
- final Intent intent = new Intent(
- "com.robert.maps.action.SHOW_POINTS");
-
+ final Intent intent = new Intent(INTENT);
intent.putStringArrayListExtra("locations", locations);
-
activity.startActivity(intent);
return true;
diff --git a/src/cgeo/geocaching/apps/cache/navi/RadarApp.java b/src/cgeo/geocaching/apps/cache/navi/RadarApp.java
index c106446..87e6368 100644
--- a/src/cgeo/geocaching/apps/cache/navi/RadarApp.java
+++ b/src/cgeo/geocaching/apps/cache/navi/RadarApp.java
@@ -21,11 +21,15 @@ class RadarApp extends AbstractNavigationApp implements NavigationApp {
super(res.getString(R.string.cache_menu_radar), INTENT, PACKAGE_NAME);
}
- private static void navigateTo(Activity activity, final Geopoint coords) {
+ private static boolean navigateTo(Activity activity, final Geopoint coords) {
+ if (coords == null) {
+ return false;
+ }
Intent radarIntent = new Intent(INTENT);
radarIntent.putExtra("latitude", (float) coords.getLatitude());
radarIntent.putExtra("longitude", (float) coords.getLongitude());
activity.startActivity(radarIntent);
+ return true;
}
@Override
@@ -33,21 +37,11 @@ class RadarApp extends AbstractNavigationApp implements NavigationApp {
cgCache cache,
final UUID searchId, cgWaypoint waypoint, final Geopoint coords) {
if (cache != null) {
- if (cache.coords != null) {
- navigateTo(activity, cache.coords);
- return true;
- }
+ return navigateTo(activity, cache.coords);
}
if (waypoint != null) {
- if (waypoint.coords != null) {
- navigateTo(activity, waypoint.coords);
- return true;
- }
- }
- if (coords != null) {
- navigateTo(activity, coords);
- return true;
+ return navigateTo(activity, waypoint.coords);
}
- return false;
+ return navigateTo(activity, coords);
}
}
diff --git a/src/cgeo/geocaching/apps/cache/navi/StreetviewApp.java b/src/cgeo/geocaching/apps/cache/navi/StreetviewApp.java
index f699987..8dae3c9 100644
--- a/src/cgeo/geocaching/apps/cache/navi/StreetviewApp.java
+++ b/src/cgeo/geocaching/apps/cache/navi/StreetviewApp.java
@@ -39,6 +39,8 @@ class StreetviewApp extends AbstractNavigationApp implements NavigationApp {
startActivity(activity, cache.coords);
} else if (waypoint != null && waypoint.coords != null) {
startActivity(activity, waypoint.coords);
+ } else if (coords != null) {
+ startActivity(activity, coords);
}
return true;
@@ -51,7 +53,7 @@ class StreetviewApp extends AbstractNavigationApp implements NavigationApp {
return false;
}
- private void startActivity(Activity activity, final Geopoint coords) {
+ private static void startActivity(Activity activity, final Geopoint coords) {
activity.startActivity(new Intent(Intent.ACTION_VIEW,
Uri.parse("google.streetview:cbll=" + coords.getLatitude() + "," + coords.getLongitude())));
}