aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSamuel Tardieu <sam@rfc1149.net>2011-10-24 23:49:36 +0200
committerSamuel Tardieu <sam@rfc1149.net>2011-10-24 23:49:36 +0200
commit3bec4991410eabe8d8c80c214e30c149bb6bee3d (patch)
treed875c6a342d121d8c20eb175fb7b6051b1f4ca9c
parent980756db69a32c6a845c51f4a229c583c6dec70f (diff)
parentb6d19eeea75e255c40756b59e1c977988082589f (diff)
downloadcgeo-3bec4991410eabe8d8c80c214e30c149bb6bee3d.zip
cgeo-3bec4991410eabe8d8c80c214e30c149bb6bee3d.tar.gz
cgeo-3bec4991410eabe8d8c80c214e30c149bb6bee3d.tar.bz2
Merge branch 'fix-707' into upstream
-rw-r--r--main/src/cgeo/geocaching/apps/cache/navi/GoogleMapsApp.java7
-rw-r--r--main/src/cgeo/geocaching/apps/cache/navi/GoogleNavigationApp.java7
-rw-r--r--main/src/cgeo/geocaching/apps/cache/navi/InternalMap.java9
-rw-r--r--main/src/cgeo/geocaching/apps/cache/navi/LocusApp.java4
-rw-r--r--main/src/cgeo/geocaching/apps/cache/navi/NavigationApp.java5
-rw-r--r--main/src/cgeo/geocaching/apps/cache/navi/NavigationAppFactory.java7
-rw-r--r--main/src/cgeo/geocaching/apps/cache/navi/OruxMapsApp.java5
-rw-r--r--main/src/cgeo/geocaching/apps/cache/navi/RMapsApp.java4
-rw-r--r--main/src/cgeo/geocaching/apps/cache/navi/RadarApp.java5
-rw-r--r--main/src/cgeo/geocaching/apps/cache/navi/StaticMapApp.java5
-rw-r--r--main/src/cgeo/geocaching/apps/cache/navi/StreetviewApp.java5
-rw-r--r--main/src/cgeo/geocaching/apps/cachelist/CacheListApp.java4
-rw-r--r--main/src/cgeo/geocaching/apps/cachelist/CacheListAppFactory.java8
-rw-r--r--main/src/cgeo/geocaching/apps/cachelist/InternalCacheListMap.java6
-rw-r--r--main/src/cgeo/geocaching/apps/cachelist/LocusCacheListApp.java4
-rw-r--r--main/src/cgeo/geocaching/cgBase.java65
-rw-r--r--main/src/cgeo/geocaching/cgSearch.java72
-rw-r--r--main/src/cgeo/geocaching/cgeoapplication.java158
-rw-r--r--main/src/cgeo/geocaching/cgeocaches.java81
-rw-r--r--main/src/cgeo/geocaching/cgeodetail.java29
-rw-r--r--main/src/cgeo/geocaching/cgeogpxes.java11
-rw-r--r--main/src/cgeo/geocaching/connector/AbstractConnector.java4
-rw-r--r--main/src/cgeo/geocaching/connector/GCConnector.java7
-rw-r--r--main/src/cgeo/geocaching/connector/IConnector.java4
-rw-r--r--main/src/cgeo/geocaching/connector/opencaching/ApiOpenCachingConnector.java5
-rw-r--r--main/src/cgeo/geocaching/files/GPXParser.java9
-rw-r--r--main/src/cgeo/geocaching/files/LocParser.java5
-rw-r--r--main/src/cgeo/geocaching/maps/CGeoMap.java64
-rw-r--r--tests/src/cgeo/geocaching/cgeoApplicationTest.java5
29 files changed, 290 insertions, 314 deletions
diff --git a/main/src/cgeo/geocaching/apps/cache/navi/GoogleMapsApp.java b/main/src/cgeo/geocaching/apps/cache/navi/GoogleMapsApp.java
index 961773f..cfab5d2 100644
--- a/main/src/cgeo/geocaching/apps/cache/navi/GoogleMapsApp.java
+++ b/main/src/cgeo/geocaching/apps/cache/navi/GoogleMapsApp.java
@@ -1,9 +1,10 @@
package cgeo.geocaching.apps.cache.navi;
import cgeo.geocaching.R;
+import cgeo.geocaching.Settings;
import cgeo.geocaching.cgCache;
import cgeo.geocaching.cgGeo;
-import cgeo.geocaching.Settings;
+import cgeo.geocaching.cgSearch;
import cgeo.geocaching.cgWaypoint;
import cgeo.geocaching.activity.ActivityMixin;
import cgeo.geocaching.geopoint.Geopoint;
@@ -15,8 +16,6 @@ import android.content.res.Resources;
import android.net.Uri;
import android.util.Log;
-import java.util.UUID;
-
class GoogleMapsApp extends AbstractNavigationApp implements NavigationApp {
GoogleMapsApp(final Resources res) {
@@ -30,7 +29,7 @@ class GoogleMapsApp extends AbstractNavigationApp implements NavigationApp {
public boolean invoke(cgGeo geo, Activity activity, Resources res,
cgCache cache,
- final UUID searchId, cgWaypoint waypoint, final Geopoint coords) {
+ final cgSearch search, cgWaypoint waypoint, final Geopoint coords) {
if (cache == null && waypoint == null && coords == null) {
return false;
}
diff --git a/main/src/cgeo/geocaching/apps/cache/navi/GoogleNavigationApp.java b/main/src/cgeo/geocaching/apps/cache/navi/GoogleNavigationApp.java
index 44a4cbd..20b012d 100644
--- a/main/src/cgeo/geocaching/apps/cache/navi/GoogleNavigationApp.java
+++ b/main/src/cgeo/geocaching/apps/cache/navi/GoogleNavigationApp.java
@@ -1,9 +1,10 @@
package cgeo.geocaching.apps.cache.navi;
import cgeo.geocaching.R;
+import cgeo.geocaching.Settings;
import cgeo.geocaching.cgCache;
import cgeo.geocaching.cgGeo;
-import cgeo.geocaching.Settings;
+import cgeo.geocaching.cgSearch;
import cgeo.geocaching.cgWaypoint;
import cgeo.geocaching.activity.ActivityMixin;
import cgeo.geocaching.geopoint.Geopoint;
@@ -15,8 +16,6 @@ import android.content.res.Resources;
import android.net.Uri;
import android.util.Log;
-import java.util.UUID;
-
class GoogleNavigationApp extends AbstractNavigationApp implements
NavigationApp {
@@ -32,7 +31,7 @@ class GoogleNavigationApp extends AbstractNavigationApp implements
@Override
public boolean invoke(final cgGeo geo, final Activity activity, final Resources res,
final cgCache cache,
- final UUID searchId, final cgWaypoint waypoint, final Geopoint coords) {
+ final cgSearch search, final cgWaypoint waypoint, final Geopoint coords) {
if (activity == null) {
return false;
}
diff --git a/main/src/cgeo/geocaching/apps/cache/navi/InternalMap.java b/main/src/cgeo/geocaching/apps/cache/navi/InternalMap.java
index 0594558..05bbad3 100644
--- a/main/src/cgeo/geocaching/apps/cache/navi/InternalMap.java
+++ b/main/src/cgeo/geocaching/apps/cache/navi/InternalMap.java
@@ -3,6 +3,7 @@ package cgeo.geocaching.apps.cache.navi;
import cgeo.geocaching.R;
import cgeo.geocaching.cgCache;
import cgeo.geocaching.cgGeo;
+import cgeo.geocaching.cgSearch;
import cgeo.geocaching.cgWaypoint;
import cgeo.geocaching.enumerations.WaypointType;
import cgeo.geocaching.geopoint.Geopoint;
@@ -11,8 +12,6 @@ import cgeo.geocaching.maps.CGeoMap;
import android.app.Activity;
import android.content.res.Resources;
-import java.util.UUID;
-
class InternalMap extends AbstractInternalMap implements
NavigationApp {
@@ -23,9 +22,9 @@ class InternalMap extends AbstractInternalMap implements
@Override
public boolean invoke(cgGeo geo, Activity activity, Resources res,
cgCache cache,
- final UUID searchId, cgWaypoint waypoint, final Geopoint coords) {
- if (searchId != null) {
- CGeoMap.startActivitySearch(activity, searchId, cache != null ? cache.geocode : null, true);
+ final cgSearch search, cgWaypoint waypoint, final Geopoint coords) {
+ if (search != null) {
+ CGeoMap.startActivitySearch(activity, search, cache != null ? cache.geocode : null, true);
}
else if (cache != null) {
CGeoMap.startActivityGeoCode(activity, cache.geocode);
diff --git a/main/src/cgeo/geocaching/apps/cache/navi/LocusApp.java b/main/src/cgeo/geocaching/apps/cache/navi/LocusApp.java
index 305ded2..b174f14 100644
--- a/main/src/cgeo/geocaching/apps/cache/navi/LocusApp.java
+++ b/main/src/cgeo/geocaching/apps/cache/navi/LocusApp.java
@@ -2,6 +2,7 @@ package cgeo.geocaching.apps.cache.navi;
import cgeo.geocaching.cgCache;
import cgeo.geocaching.cgGeo;
+import cgeo.geocaching.cgSearch;
import cgeo.geocaching.cgWaypoint;
import cgeo.geocaching.apps.AbstractLocusApp;
import cgeo.geocaching.geopoint.Geopoint;
@@ -10,7 +11,6 @@ import android.app.Activity;
import android.content.res.Resources;
import java.util.ArrayList;
-import java.util.UUID;
class LocusApp extends AbstractLocusApp implements NavigationApp {
@@ -27,7 +27,7 @@ class LocusApp extends AbstractLocusApp implements NavigationApp {
*/
@Override
public boolean invoke(cgGeo geo, Activity activity, Resources res, cgCache cache,
- final UUID searchId, cgWaypoint waypoint, final Geopoint coords) {
+ final cgSearch search, cgWaypoint waypoint, final Geopoint coords) {
if (cache == null && waypoint == null && coords == null) {
return false;
diff --git a/main/src/cgeo/geocaching/apps/cache/navi/NavigationApp.java b/main/src/cgeo/geocaching/apps/cache/navi/NavigationApp.java
index ef0a578..f52cc42 100644
--- a/main/src/cgeo/geocaching/apps/cache/navi/NavigationApp.java
+++ b/main/src/cgeo/geocaching/apps/cache/navi/NavigationApp.java
@@ -2,6 +2,7 @@ package cgeo.geocaching.apps.cache.navi;
import cgeo.geocaching.cgCache;
import cgeo.geocaching.cgGeo;
+import cgeo.geocaching.cgSearch;
import cgeo.geocaching.cgWaypoint;
import cgeo.geocaching.apps.App;
import cgeo.geocaching.geopoint.Geopoint;
@@ -9,12 +10,10 @@ import cgeo.geocaching.geopoint.Geopoint;
import android.app.Activity;
import android.content.res.Resources;
-import java.util.UUID;
-
interface NavigationApp extends App {
public boolean invoke(final cgGeo geo, final Activity activity,
final Resources res,
final cgCache cache,
- final UUID searchId, final cgWaypoint waypoint,
+ final cgSearch search, 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 1ee7c23..56bcb5d 100644
--- a/main/src/cgeo/geocaching/apps/cache/navi/NavigationAppFactory.java
+++ b/main/src/cgeo/geocaching/apps/cache/navi/NavigationAppFactory.java
@@ -3,6 +3,7 @@ package cgeo.geocaching.apps.cache.navi;
import cgeo.geocaching.Settings;
import cgeo.geocaching.cgCache;
import cgeo.geocaching.cgGeo;
+import cgeo.geocaching.cgSearch;
import cgeo.geocaching.cgWaypoint;
import cgeo.geocaching.apps.AbstractAppFactory;
import cgeo.geocaching.geopoint.Geopoint;
@@ -15,8 +16,6 @@ import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
-import java.util.UUID;
-
public final class NavigationAppFactory extends AbstractAppFactory {
private static NavigationApp[] apps = new NavigationApp[] {};
@@ -56,12 +55,12 @@ public final class NavigationAppFactory extends AbstractAppFactory {
public static boolean onMenuItemSelected(final MenuItem item,
final cgGeo geo, Activity activity, Resources res,
cgCache cache,
- final UUID searchId, cgWaypoint waypoint, final Geopoint destination) {
+ final cgSearch search, cgWaypoint waypoint, final Geopoint destination) {
NavigationApp app = (NavigationApp) getAppFromMenuItem(item, apps);
if (app != null) {
try {
return app.invoke(geo, activity, res, cache,
- searchId, waypoint, destination);
+ search, waypoint, destination);
} catch (Exception e) {
Log.e(Settings.tag, "NavigationAppFactory.onMenuItemSelected: " + e.toString());
}
diff --git a/main/src/cgeo/geocaching/apps/cache/navi/OruxMapsApp.java b/main/src/cgeo/geocaching/apps/cache/navi/OruxMapsApp.java
index 71430ae..8e1373d 100644
--- a/main/src/cgeo/geocaching/apps/cache/navi/OruxMapsApp.java
+++ b/main/src/cgeo/geocaching/apps/cache/navi/OruxMapsApp.java
@@ -3,6 +3,7 @@ package cgeo.geocaching.apps.cache.navi;
import cgeo.geocaching.R;
import cgeo.geocaching.cgCache;
import cgeo.geocaching.cgGeo;
+import cgeo.geocaching.cgSearch;
import cgeo.geocaching.cgWaypoint;
import cgeo.geocaching.geopoint.Geopoint;
@@ -10,8 +11,6 @@ import android.app.Activity;
import android.content.Intent;
import android.content.res.Resources;
-import java.util.UUID;
-
class OruxMapsApp extends AbstractNavigationApp implements NavigationApp {
private static final String INTENT = "com.oruxmaps.VIEW_MAP_ONLINE";
@@ -23,7 +22,7 @@ class OruxMapsApp extends AbstractNavigationApp implements NavigationApp {
@Override
public boolean invoke(cgGeo geo, Activity activity, Resources res,
cgCache cache,
- final UUID searchId, cgWaypoint waypoint, final Geopoint coords) {
+ final cgSearch search, cgWaypoint waypoint, final Geopoint coords) {
if (cache == null && waypoint == null && coords == null) {
return false;
}
diff --git a/main/src/cgeo/geocaching/apps/cache/navi/RMapsApp.java b/main/src/cgeo/geocaching/apps/cache/navi/RMapsApp.java
index 2d27493..16fc04d 100644
--- a/main/src/cgeo/geocaching/apps/cache/navi/RMapsApp.java
+++ b/main/src/cgeo/geocaching/apps/cache/navi/RMapsApp.java
@@ -3,6 +3,7 @@ package cgeo.geocaching.apps.cache.navi;
import cgeo.geocaching.R;
import cgeo.geocaching.cgCache;
import cgeo.geocaching.cgGeo;
+import cgeo.geocaching.cgSearch;
import cgeo.geocaching.cgWaypoint;
import cgeo.geocaching.geopoint.Geopoint;
@@ -12,7 +13,6 @@ import android.content.res.Resources;
import java.util.ArrayList;
import java.util.Locale;
-import java.util.UUID;
class RMapsApp extends AbstractNavigationApp implements NavigationApp {
@@ -25,7 +25,7 @@ class RMapsApp extends AbstractNavigationApp implements NavigationApp {
@Override
public boolean invoke(cgGeo geo, Activity activity, Resources res,
cgCache cache,
- final UUID searchId, cgWaypoint waypoint, final Geopoint coords) {
+ final cgSearch search, cgWaypoint waypoint, final Geopoint coords) {
if (cache == null && waypoint == null && coords == null) {
return false;
}
diff --git a/main/src/cgeo/geocaching/apps/cache/navi/RadarApp.java b/main/src/cgeo/geocaching/apps/cache/navi/RadarApp.java
index 87e6368..a9584e1 100644
--- a/main/src/cgeo/geocaching/apps/cache/navi/RadarApp.java
+++ b/main/src/cgeo/geocaching/apps/cache/navi/RadarApp.java
@@ -3,6 +3,7 @@ package cgeo.geocaching.apps.cache.navi;
import cgeo.geocaching.R;
import cgeo.geocaching.cgCache;
import cgeo.geocaching.cgGeo;
+import cgeo.geocaching.cgSearch;
import cgeo.geocaching.cgWaypoint;
import cgeo.geocaching.geopoint.Geopoint;
@@ -10,8 +11,6 @@ import android.app.Activity;
import android.content.Intent;
import android.content.res.Resources;
-import java.util.UUID;
-
class RadarApp extends AbstractNavigationApp implements NavigationApp {
private static final String INTENT = "com.google.android.radar.SHOW_RADAR";
@@ -35,7 +34,7 @@ class RadarApp extends AbstractNavigationApp implements NavigationApp {
@Override
public boolean invoke(cgGeo geo, Activity activity, Resources res,
cgCache cache,
- final UUID searchId, cgWaypoint waypoint, final Geopoint coords) {
+ final cgSearch search, cgWaypoint waypoint, final Geopoint coords) {
if (cache != null) {
return navigateTo(activity, cache.coords);
}
diff --git a/main/src/cgeo/geocaching/apps/cache/navi/StaticMapApp.java b/main/src/cgeo/geocaching/apps/cache/navi/StaticMapApp.java
index 0967925..c29ca9f 100644
--- a/main/src/cgeo/geocaching/apps/cache/navi/StaticMapApp.java
+++ b/main/src/cgeo/geocaching/apps/cache/navi/StaticMapApp.java
@@ -3,6 +3,7 @@ package cgeo.geocaching.apps.cache.navi;
import cgeo.geocaching.R;
import cgeo.geocaching.cgCache;
import cgeo.geocaching.cgGeo;
+import cgeo.geocaching.cgSearch;
import cgeo.geocaching.cgWaypoint;
import cgeo.geocaching.cgeosmaps;
import cgeo.geocaching.activity.ActivityMixin;
@@ -13,8 +14,6 @@ import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
-import java.util.UUID;
-
class StaticMapApp extends AbstractNavigationApp implements
NavigationApp {
@@ -30,7 +29,7 @@ class StaticMapApp extends AbstractNavigationApp implements
@Override
public boolean invoke(cgGeo geo, Activity activity, Resources res,
cgCache cache,
- final UUID searchId, cgWaypoint waypoint, final Geopoint coords) {
+ final cgSearch search, cgWaypoint waypoint, final Geopoint coords) {
if (cache == null || cache.reason == 0) {
ActivityMixin.showToast(activity, res.getString(R.string.err_detail_no_map_static));
diff --git a/main/src/cgeo/geocaching/apps/cache/navi/StreetviewApp.java b/main/src/cgeo/geocaching/apps/cache/navi/StreetviewApp.java
index 8dae3c9..e443ff0 100644
--- a/main/src/cgeo/geocaching/apps/cache/navi/StreetviewApp.java
+++ b/main/src/cgeo/geocaching/apps/cache/navi/StreetviewApp.java
@@ -3,6 +3,7 @@ package cgeo.geocaching.apps.cache.navi;
import cgeo.geocaching.R;
import cgeo.geocaching.cgCache;
import cgeo.geocaching.cgGeo;
+import cgeo.geocaching.cgSearch;
import cgeo.geocaching.cgWaypoint;
import cgeo.geocaching.activity.ActivityMixin;
import cgeo.geocaching.geopoint.Geopoint;
@@ -14,8 +15,6 @@ import android.content.Intent;
import android.content.res.Resources;
import android.net.Uri;
-import java.util.UUID;
-
class StreetviewApp extends AbstractNavigationApp implements NavigationApp {
StreetviewApp(final Resources res) {
@@ -29,7 +28,7 @@ class StreetviewApp extends AbstractNavigationApp implements NavigationApp {
public boolean invoke(cgGeo geo, Activity activity, Resources res,
cgCache cache,
- final UUID searchId, cgWaypoint waypoint, final Geopoint coords) {
+ final cgSearch search, cgWaypoint waypoint, final Geopoint coords) {
if (cache == null && waypoint == null && coords == null) {
return false;
}
diff --git a/main/src/cgeo/geocaching/apps/cachelist/CacheListApp.java b/main/src/cgeo/geocaching/apps/cachelist/CacheListApp.java
index c4d51d2..2788d2b 100644
--- a/main/src/cgeo/geocaching/apps/cachelist/CacheListApp.java
+++ b/main/src/cgeo/geocaching/apps/cachelist/CacheListApp.java
@@ -2,18 +2,18 @@ package cgeo.geocaching.apps.cachelist;
import cgeo.geocaching.cgCache;
import cgeo.geocaching.cgGeo;
+import cgeo.geocaching.cgSearch;
import cgeo.geocaching.apps.App;
import android.app.Activity;
import android.content.res.Resources;
import java.util.List;
-import java.util.UUID;
interface CacheListApp extends App {
boolean invoke(final cgGeo geo, final List<cgCache> caches,
final Activity activity, final Resources res,
- final UUID searchId);
+ final cgSearch search);
}
diff --git a/main/src/cgeo/geocaching/apps/cachelist/CacheListAppFactory.java b/main/src/cgeo/geocaching/apps/cachelist/CacheListAppFactory.java
index 5b3dc9a..46ceb8b 100644
--- a/main/src/cgeo/geocaching/apps/cachelist/CacheListAppFactory.java
+++ b/main/src/cgeo/geocaching/apps/cachelist/CacheListAppFactory.java
@@ -1,9 +1,10 @@
package cgeo.geocaching.apps.cachelist;
import cgeo.geocaching.R;
+import cgeo.geocaching.Settings;
import cgeo.geocaching.cgCache;
import cgeo.geocaching.cgGeo;
-import cgeo.geocaching.Settings;
+import cgeo.geocaching.cgSearch;
import cgeo.geocaching.apps.AbstractAppFactory;
import org.apache.commons.lang3.ArrayUtils;
@@ -17,7 +18,6 @@ import android.view.SubMenu;
import java.util.ArrayList;
import java.util.List;
-import java.util.UUID;
public final class CacheListAppFactory extends AbstractAppFactory {
private static CacheListApp[] apps = new CacheListApp[] {};
@@ -64,11 +64,11 @@ 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) {
+ final cgSearch search) {
CacheListApp app = (CacheListApp) getAppFromMenuItem(item, apps);
if (app != null) {
try {
- return app.invoke(geo, caches, activity, res, searchId);
+ return app.invoke(geo, caches, activity, res, search);
} catch (Exception e) {
Log.e(Settings.tag, "CacheListAppFactory.onMenuItemSelected: " + e.toString());
}
diff --git a/main/src/cgeo/geocaching/apps/cachelist/InternalCacheListMap.java b/main/src/cgeo/geocaching/apps/cachelist/InternalCacheListMap.java
index 6de5c13..3038872 100644
--- a/main/src/cgeo/geocaching/apps/cachelist/InternalCacheListMap.java
+++ b/main/src/cgeo/geocaching/apps/cachelist/InternalCacheListMap.java
@@ -3,6 +3,7 @@ package cgeo.geocaching.apps.cachelist;
import cgeo.geocaching.R;
import cgeo.geocaching.cgCache;
import cgeo.geocaching.cgGeo;
+import cgeo.geocaching.cgSearch;
import cgeo.geocaching.apps.AbstractApp;
import cgeo.geocaching.maps.CGeoMap;
@@ -11,7 +12,6 @@ import android.content.Context;
import android.content.res.Resources;
import java.util.List;
-import java.util.UUID;
class InternalCacheListMap extends AbstractApp implements CacheListApp {
@@ -25,8 +25,8 @@ class InternalCacheListMap extends AbstractApp implements CacheListApp {
}
@Override
- public boolean invoke(cgGeo geo, List<cgCache> caches, Activity activity, Resources res, final UUID searchId) {
- CGeoMap.startActivitySearch(activity, searchId, null, false);
+ public boolean invoke(cgGeo geo, List<cgCache> caches, Activity activity, Resources res, final cgSearch search) {
+ CGeoMap.startActivitySearch(activity, search, null, false);
return true;
}
}
diff --git a/main/src/cgeo/geocaching/apps/cachelist/LocusCacheListApp.java b/main/src/cgeo/geocaching/apps/cachelist/LocusCacheListApp.java
index 4cce8d7..eddd6ac 100644
--- a/main/src/cgeo/geocaching/apps/cachelist/LocusCacheListApp.java
+++ b/main/src/cgeo/geocaching/apps/cachelist/LocusCacheListApp.java
@@ -2,6 +2,7 @@ package cgeo.geocaching.apps.cachelist;
import cgeo.geocaching.cgCache;
import cgeo.geocaching.cgGeo;
+import cgeo.geocaching.cgSearch;
import cgeo.geocaching.apps.AbstractLocusApp;
import org.apache.commons.collections.CollectionUtils;
@@ -10,7 +11,6 @@ import android.app.Activity;
import android.content.res.Resources;
import java.util.List;
-import java.util.UUID;
class LocusCacheListApp extends AbstractLocusApp implements CacheListApp {
@@ -26,7 +26,7 @@ class LocusCacheListApp extends AbstractLocusApp implements CacheListApp {
*/
@Override
public boolean invoke(cgGeo geo, List<cgCache> cacheList, Activity activity, Resources res,
- final UUID searchId) {
+ final cgSearch search) {
if (CollectionUtils.isEmpty(cacheList)) {
return false;
}
diff --git a/main/src/cgeo/geocaching/cgBase.java b/main/src/cgeo/geocaching/cgBase.java
index 816453f..66a5891 100644
--- a/main/src/cgeo/geocaching/cgBase.java
+++ b/main/src/cgeo/geocaching/cgBase.java
@@ -78,7 +78,6 @@ import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
-import java.util.UUID;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -2003,19 +2002,19 @@ public class cgBase {
}
}
- public UUID searchByNextPage(cgSearchThread thread, final UUID searchId, int reason, boolean showCaptcha) {
- final String[] viewstates = app.getViewstates(searchId);
+ public cgSearch searchByNextPage(cgSearchThread thread, final cgSearch search, int reason, boolean showCaptcha) {
+ final String[] viewstates = cgeoapplication.getViewstates(search);
- final String url = app.getUrl(searchId);
+ final String url = cgeoapplication.getUrl(search);
if (StringUtils.isBlank(url)) {
Log.e(Settings.tag, "cgeoBase.searchByNextPage: No url found");
- return searchId;
+ return search;
}
if (isEmpty(viewstates)) {
Log.e(Settings.tag, "cgeoBase.searchByNextPage: No viewstate given");
- return searchId;
+ return search;
}
// As in the original code, remove the query string
@@ -2034,39 +2033,39 @@ public class cgBase {
} else if (loginState == StatusCode.NO_LOGIN_INFO_STORED) {
Log.i(Settings.tag, "Working as guest.");
} else {
- app.setError(searchId, loginState);
+ cgeoapplication.setError(search, loginState);
Log.e(Settings.tag, "cgeoBase.searchByNextPage: Can not log in geocaching");
- return searchId;
+ return search;
}
}
if (StringUtils.isBlank(page)) {
Log.e(Settings.tag, "cgeoBase.searchByNextPage: No data from server");
- return searchId;
+ return search;
}
final cgCacheWrap caches = parseSearch(thread, url, page, showCaptcha);
if (caches == null || CollectionUtils.isEmpty(caches.cacheList)) {
Log.e(Settings.tag, "cgeoBase.searchByNextPage: No cache parsed");
- return searchId;
+ return search;
}
// save to application
- app.setError(searchId, caches.error);
- app.setViewstates(searchId, caches.viewstates);
+ cgeoapplication.setError(search, caches.error);
+ cgeoapplication.setViewstates(search, caches.viewstates);
final List<cgCache> cacheList = new ArrayList<cgCache>();
for (cgCache cache : caches.cacheList) {
- app.addGeocode(searchId, cache.geocode);
+ cgeoapplication.addGeocode(search, cache.geocode);
cacheList.add(cache);
}
- app.addSearch(searchId, cacheList, true, reason);
+ app.addSearch(search, cacheList, true, reason);
- return searchId;
+ return search;
}
- public UUID searchByGeocode(final String geocode, final String guid, final int reason, final boolean forceReload, final Handler handler) {
+ public cgSearch searchByGeocode(final String geocode, final String guid, final int reason, final boolean forceReload, final Handler handler) {
final cgSearch search = new cgSearch();
if (StringUtils.isBlank(geocode) && StringUtils.isBlank(guid)) {
@@ -2086,23 +2085,23 @@ public class cgBase {
cacheList.clear();
cacheList = null;
- return search.getCurrentId();
+ return search;
}
return ConnectorFactory.getConnector(geocode).searchByGeocode(this, geocode, guid, app, search, reason, handler);
}
- public UUID searchByOffline(final Geopoint coords, final String cacheType, final int list) {
+ public cgSearch searchByOffline(final Geopoint coords, final String cacheType, final int list) {
if (app == null) {
Log.e(Settings.tag, "cgeoBase.searchByOffline: No application found");
return null;
}
final cgSearch search = app.getBatchOfStoredCaches(true, coords, cacheType, list);
search.totalCnt = app.getAllStoredCachesCount(true, cacheType, list);
- return search.getCurrentId();
+ return search;
}
- public UUID searchByHistory(final String cacheType) {
+ public cgSearch searchByHistory(final String cacheType) {
if (app == null) {
Log.e(Settings.tag, "cgeoBase.searchByHistory: No application found");
return null;
@@ -2111,7 +2110,7 @@ public class cgBase {
final cgSearch search = app.getHistoryOfCaches(true, cacheType);
search.totalCnt = app.getAllHistoricCachesCount();
- return search.getCurrentId();
+ return search;
}
/**
@@ -2124,7 +2123,7 @@ public class cgBase {
* the parameters to add to the request URI
* @return
*/
- private UUID searchByAny(final cgSearchThread thread, final String cacheType, final boolean my, final int reason, final boolean showCaptcha, final Parameters params) {
+ private cgSearch searchByAny(final cgSearchThread thread, final String cacheType, final boolean my, final int reason, final boolean showCaptcha, final Parameters params) {
final cgSearch search = new cgSearch();
insertCacheType(params, cacheType);
@@ -2151,15 +2150,15 @@ public class cgBase {
app.addSearch(search, cacheList, true, reason);
- return search.getCurrentId();
+ return search;
}
- public UUID searchByCoords(final cgSearchThread thread, final Geopoint coords, final String cacheType, final int reason, final boolean showCaptcha) {
+ public cgSearch searchByCoords(final cgSearchThread thread, final Geopoint coords, final String cacheType, final int reason, final boolean showCaptcha) {
final Parameters params = new Parameters("lat", Double.toString(coords.getLatitude()), "lng", Double.toString(coords.getLongitude()));
return searchByAny(thread, cacheType, false, reason, showCaptcha, params);
}
- public UUID searchByKeyword(final cgSearchThread thread, final String keyword, final String cacheType, final int reason, final boolean showCaptcha) {
+ public cgSearch searchByKeyword(final cgSearchThread thread, final String keyword, final String cacheType, final int reason, final boolean showCaptcha) {
if (StringUtils.isBlank(keyword)) {
Log.e(Settings.tag, "cgeoBase.searchByKeyword: No keyword given");
return null;
@@ -2169,7 +2168,7 @@ public class cgBase {
return searchByAny(thread, cacheType, false, reason, showCaptcha, params);
}
- public UUID searchByUsername(final cgSearchThread thread, final String userName, final String cacheType, final int reason, final boolean showCaptcha) {
+ public cgSearch searchByUsername(final cgSearchThread thread, final String userName, final String cacheType, final int reason, final boolean showCaptcha) {
if (StringUtils.isBlank(userName)) {
Log.e(Settings.tag, "cgeoBase.searchByUsername: No user name given");
return null;
@@ -2186,7 +2185,7 @@ public class cgBase {
return searchByAny(thread, cacheType, my, reason, showCaptcha, params);
}
- public UUID searchByOwner(final cgSearchThread thread, final String userName, final String cacheType, final int reason, final boolean showCaptcha) {
+ public cgSearch searchByOwner(final cgSearchThread thread, final String userName, final String cacheType, final int reason, final boolean showCaptcha) {
if (StringUtils.isBlank(userName)) {
Log.e(Settings.tag, "cgeoBase.searchByOwner: No user name given");
return null;
@@ -2196,7 +2195,7 @@ public class cgBase {
return searchByAny(thread, cacheType, false, reason, showCaptcha, params);
}
- public UUID searchByViewport(final String userToken, final double latMin, final double latMax, final double lonMin, final double lonMax, int reason) {
+ public cgSearch searchByViewport(final String userToken, final double latMin, final double latMax, final double lonMin, final double lonMax, int reason) {
final cgSearch search = new cgSearch();
String page = null;
@@ -2225,7 +2224,7 @@ public class cgBase {
app.addSearch(search, cacheList, true, reason);
- return search.getCurrentId();
+ return search;
}
private static String requestJSONgc(final String uri, final String params) {
@@ -2960,12 +2959,12 @@ public class cgBase {
if (cache != null) {
// only reload the cache, if it was already stored or has not all details (by checking the description)
if (cache.reason > 0 || StringUtils.isBlank(cache.getDescription())) {
- final UUID searchId = searchByGeocode(cache.geocode, null, listId, false, null);
- cache = app.getCache(searchId);
+ final cgSearch search = searchByGeocode(cache.geocode, null, listId, false, null);
+ cache = app.getCache(search);
}
} else if (StringUtils.isNotBlank(geocode)) {
- final UUID searchId = searchByGeocode(geocode, null, listId, false, null);
- cache = app.getCache(searchId);
+ final cgSearch search = searchByGeocode(geocode, null, listId, false, null);
+ cache = app.getCache(search);
}
if (cache == null) {
diff --git a/main/src/cgeo/geocaching/cgSearch.java b/main/src/cgeo/geocaching/cgSearch.java
index fb217fb..b96b1cd 100644
--- a/main/src/cgeo/geocaching/cgSearch.java
+++ b/main/src/cgeo/geocaching/cgSearch.java
@@ -2,40 +2,86 @@ package cgeo.geocaching;
import cgeo.geocaching.enumerations.StatusCode;
+import android.os.Parcel;
+import android.os.Parcelable;
+
import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
-import java.util.UUID;
-public class cgSearch {
- private UUID id;
- private List<String> geocodes = new ArrayList<String>();
+public class cgSearch implements Parcelable {
+ final private List<String> geocodes;
public StatusCode error = null;
public String url = "";
public String[] viewstates = null;
public int totalCnt = 0;
+ final public static Parcelable.Creator<cgSearch> CREATOR = new Parcelable.Creator<cgSearch>() {
+ public cgSearch createFromParcel(Parcel in) {
+ return new cgSearch(in);
+ }
+
+ public cgSearch[] newArray(int size) {
+ return new cgSearch[size];
+ }
+ };
+
public cgSearch() {
- id = UUID.randomUUID();
+ this((List<String>) null);
}
- public UUID getCurrentId() {
- return id;
+ public cgSearch(final List<String> geocodes) {
+ if (geocodes == null) {
+ this.geocodes = new ArrayList<String>();
+ } else {
+ this.geocodes = new ArrayList<String>(geocodes.size());
+ this.geocodes.addAll(geocodes);
+ }
+ }
+
+ public cgSearch(final Parcel in) {
+ geocodes = new ArrayList<String>();
+ in.readStringList(geocodes);
+ error = (StatusCode) in.readSerializable();
+ url = in.readString();
+ final int length = in.readInt();
+ if (length >= 0) {
+ viewstates = new String[length];
+ in.readStringArray(viewstates);
+ }
+ totalCnt = in.readInt();
+ }
+
+ @Override
+ public void writeToParcel(final Parcel out, final int flags) {
+ out.writeStringList(geocodes);
+ out.writeSerializable(error);
+ out.writeString(url);
+ if (viewstates == null) {
+ out.writeInt(-1);
+ } else {
+ out.writeInt(viewstates.length);
+ out.writeStringArray(viewstates);
+ }
+ out.writeInt(totalCnt);
+ }
+
+ @Override
+ public int describeContents() {
+ return 0;
}
public List<String> getGeocodes() {
- return geocodes;
+ return Collections.unmodifiableList(geocodes);
}
public int getCount() {
return geocodes.size();
}
- public void addGeocode(String geocode) {
- if (geocodes == null) {
- geocodes = new ArrayList<String>();
- }
-
+ public void addGeocode(final String geocode) {
geocodes.add(geocode);
}
+
}
diff --git a/main/src/cgeo/geocaching/cgeoapplication.java b/main/src/cgeo/geocaching/cgeoapplication.java
index ac82c1a..f876552 100644
--- a/main/src/cgeo/geocaching/cgeoapplication.java
+++ b/main/src/cgeo/geocaching/cgeoapplication.java
@@ -16,7 +16,6 @@ import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import java.util.UUID;
public class cgeoapplication extends Application {
@@ -27,7 +26,6 @@ public class cgeoapplication extends Application {
private boolean geoInUse = false;
private cgDirection dir = null;
private boolean dirInUse = false;
- final private Map<UUID, cgSearch> searches = new HashMap<UUID, cgSearch>(); // information about searches
final private Map<String, cgCache> cachesCache = new HashMap<String, cgCache>(); // caching caches into memory
public boolean firstRun = true; // c:geo is just launched
public boolean showLoginToast = true; //login toast shown just once.
@@ -217,99 +215,89 @@ public class cgeoapplication extends Application {
return getStorage().getCacheidForGeocode(geocode);
}
- public StatusCode getError(final UUID searchId) {
- if (unknownSearch(searchId)) {
+ public static StatusCode getError(final cgSearch search) {
+ if (search == null) {
return null;
}
- return searches.get(searchId).error;
+ return search.error;
}
- public boolean setError(final UUID searchId, final StatusCode error) {
- if (unknownSearch(searchId)) {
+ public static boolean setError(final cgSearch search, final StatusCode error) {
+ if (search == null) {
return false;
}
- searches.get(searchId).error = error;
+ search.error = error;
return true;
}
- public String getUrl(final UUID searchId) {
- if (unknownSearch(searchId)) {
+ public static String getUrl(final cgSearch search) {
+ if (search == null) {
return null;
}
- return searches.get(searchId).url;
+ return search.url;
}
- public boolean setUrl(final UUID searchId, String url) {
- if (unknownSearch(searchId)) {
+ public static boolean setUrl(final cgSearch search, String url) {
+ if (search == null) {
return false;
}
- searches.get(searchId).url = url;
+ search.url = url;
return true;
}
- public String[] getViewstates(final UUID searchId) {
- if (unknownSearch(searchId)) {
+ public static String[] getViewstates(final cgSearch search) {
+ if (search == null) {
return null;
}
- return searches.get(searchId).viewstates;
+ return search.viewstates;
}
- public boolean setViewstates(final UUID searchId, String[] viewstates) {
- if (cgBase.isEmpty(viewstates)) {
- return false;
- }
- if (unknownSearch(searchId)) {
+ public static boolean setViewstates(final cgSearch search, String[] viewstates) {
+ if (cgBase.isEmpty(viewstates) || search == null) {
return false;
}
- searches.get(searchId).viewstates = viewstates;
+ search.viewstates = viewstates;
return true;
}
- public Integer getTotal(final UUID searchId) {
- if (unknownSearch(searchId)) {
+ public static Integer getTotal(final cgSearch search) {
+ if (search == null) {
return null;
}
- return searches.get(searchId).totalCnt;
+ return search.totalCnt;
}
- public Integer getCount(final UUID searchId) {
- if (unknownSearch(searchId)) {
+ public static Integer getCount(final cgSearch search) {
+ if (search == null) {
return 0;
}
- return searches.get(searchId).getCount();
+ return search.getCount();
}
- public boolean hasUnsavedCaches(final UUID searchId) {
- if (unknownSearch(searchId)) {
+ public boolean hasUnsavedCaches(final cgSearch search) {
+ if (search == null) {
return false;
}
- List<String> geocodes = searches.get(searchId).getGeocodes();
- if (geocodes != null) {
- for (String geocode : geocodes) {
- if (!isOffline(geocode, null)) {
- return true;
- }
+ for (final String geocode : search.getGeocodes()) {
+ if (!isOffline(geocode, null)) {
+ return true;
}
}
return false;
}
- private boolean unknownSearch(final UUID searchId) {
- return searchId == null || !searches.containsKey(searchId);
- }
-
public cgCache getCacheByGeocode(String geocode) {
return getCacheByGeocode(geocode, false, true, false, false, false, false);
}
@@ -385,8 +373,8 @@ public class cgeoapplication extends Application {
return getBounds(geocodeList);
}
- public List<Object> getBounds(final UUID searchId) {
- if (unknownSearch(searchId)) {
+ public List<Object> getBounds(final cgSearch search) {
+ if (search == null) {
return null;
}
@@ -394,7 +382,6 @@ public class cgeoapplication extends Application {
storage = new cgData(this);
}
- final cgSearch search = searches.get(searchId);
final List<String> geocodeList = search.getGeocodes();
return getBounds(geocodeList);
@@ -408,33 +395,32 @@ public class cgeoapplication extends Application {
return getStorage().getBounds(geocodes.toArray());
}
- public cgCache getCache(final UUID searchId) {
- if (unknownSearch(searchId)) {
+ public cgCache getCache(final cgSearch search) {
+ if (search == null) {
return null;
}
- cgSearch search = searches.get(searchId);
- List<String> geocodeList = search.getGeocodes();
+ final List<String> geocodeList = search.getGeocodes();
return getCacheByGeocode(geocodeList.get(0), true, true, true, true, true, true);
}
/**
- * @param searchId
+ * @param search
* @param loadWaypoints
* only load waypoints for map usage. All other callers should set this to <code>false</code>
* @return
*/
- public List<cgCache> getCaches(final UUID searchId, final boolean loadWaypoints) {
- return getCaches(searchId, null, null, null, null, false, loadWaypoints, false, false, false, true);
+ public List<cgCache> getCaches(final cgSearch search, final boolean loadWaypoints) {
+ return getCaches(search, null, null, null, null, false, loadWaypoints, false, false, false, true);
}
- public List<cgCache> getCaches(final UUID searchId, Long centerLat, Long centerLon, Long spanLat, Long spanLon) {
- return getCaches(searchId, centerLat, centerLon, spanLat, spanLon, false, true, false, false, false, true);
+ public List<cgCache> getCaches(final cgSearch search, Long centerLat, Long centerLon, Long spanLat, Long spanLon) {
+ return getCaches(search, centerLat, centerLon, spanLat, spanLon, false, true, false, false, false, true);
}
- public List<cgCache> getCaches(final UUID searchId, Long centerLat, Long centerLon, Long spanLat, Long spanLon, boolean loadA, boolean loadW, boolean loadS, boolean loadL, boolean loadI, boolean loadO) {
- if (unknownSearch(searchId)) {
+ public List<cgCache> getCaches(final cgSearch search, Long centerLat, Long centerLon, Long spanLat, Long spanLon, boolean loadA, boolean loadW, boolean loadS, boolean loadL, boolean loadI, boolean loadO) {
+ if (search == null) {
List<cgCache> cachesOut = new ArrayList<cgCache>();
final List<cgCache> cachesPre = storage.loadCaches(null, null, centerLat, centerLon, spanLat, spanLon, loadA, loadW, loadS, loadL, loadI, loadO);
@@ -448,8 +434,7 @@ public class cgeoapplication extends Application {
List<cgCache> cachesOut = new ArrayList<cgCache>();
- cgSearch search = searches.get(searchId);
- List<String> geocodeList = search.getGeocodes();
+ final List<String> geocodeList = search.getGeocodes();
// The list of geocodes is sufficient. more parameters generate an overly complex select.
final List<cgCache> cachesPre = getStorage().loadCaches(geocodeList.toArray(), null, null, null, null, null, loadA, loadW, loadS, loadL, loadI, loadO);
@@ -460,27 +445,9 @@ public class cgeoapplication extends Application {
return cachesOut;
}
- /**
- * Create new search and register it
- *
- * @param geocodes
- * the list of geocodes to search for
- * @return the newly created search, which has been added to the list of searches
- */
- private cgSearch createNewSearch(final List<String> geocodes) {
- final cgSearch search = new cgSearch();
- if (CollectionUtils.isNotEmpty(geocodes)) {
- for (final String gccode : geocodes) {
- search.addGeocode(gccode);
- }
- }
- searches.put(search.getCurrentId(), search);
- return search;
- }
-
public cgSearch getBatchOfStoredCaches(boolean detailedOnly, final Geopoint coords, String cachetype, int list) {
final List<String> geocodes = getStorage().loadBatchOfStoredGeocodes(detailedOnly, coords, cachetype, list);
- return createNewSearch(geocodes);
+ return new cgSearch(geocodes);
}
public List<cgDestination> getHistoryOfSearchedLocations() {
@@ -489,22 +456,22 @@ public class cgeoapplication extends Application {
public cgSearch getHistoryOfCaches(boolean detailedOnly, String cachetype) {
final List<String> geocodes = getStorage().loadBatchOfHistoricGeocodes(detailedOnly, cachetype);
- return createNewSearch(geocodes);
+ return new cgSearch(geocodes);
}
- public UUID getCachedInViewport(Long centerLat, Long centerLon, Long spanLat, Long spanLon, String cachetype) {
+ public cgSearch getCachedInViewport(Long centerLat, Long centerLon, Long spanLat, Long spanLon, String cachetype) {
final List<String> geocodes = getStorage().getCachedInViewport(centerLat, centerLon, spanLat, spanLon, cachetype);
- return createNewSearch(geocodes).getCurrentId();
+ return new cgSearch(geocodes);
}
- public UUID getStoredInViewport(Long centerLat, Long centerLon, Long spanLat, Long spanLon, String cachetype) {
+ public cgSearch getStoredInViewport(Long centerLat, Long centerLon, Long spanLat, Long spanLon, String cachetype) {
final List<String> geocodes = getStorage().getStoredInViewport(centerLat, centerLon, spanLat, spanLon, cachetype);
- return createNewSearch(geocodes).getCurrentId();
+ return new cgSearch(geocodes);
}
- public UUID getOfflineAll(String cachetype) {
+ public cgSearch getOfflineAll(String cachetype) {
final List<String> geocodes = getStorage().getOfflineAll(cachetype);
- return createNewSearch(geocodes).getCurrentId();
+ return new cgSearch(geocodes);
}
public int getAllStoredCachesCount(boolean detailedOnly, String cachetype, Integer list) {
@@ -561,32 +528,27 @@ public class cgeoapplication extends Application {
return getStorage().saveInventory("---", list);
}
- public void addGeocode(final UUID searchId, String geocode) {
- if (!this.searches.containsKey(searchId) || StringUtils.isBlank(geocode)) {
+ public static void addGeocode(final cgSearch search, final String geocode) {
+ if (search == null || StringUtils.isBlank(geocode)) {
return;
}
- this.searches.get(searchId).addGeocode(geocode);
+ search.addGeocode(geocode);
}
- public UUID addSearch(final UUID searchId, List<cgCache> cacheList, Boolean newItem, int reason) {
- if (!this.searches.containsKey(searchId)) {
+ public cgSearch addSearch(final cgSearch search, List<cgCache> cacheList, Boolean newItem, int reason) {
+ if (search == null) {
return null;
}
- cgSearch search = this.searches.get(searchId);
-
return addSearch(search, cacheList, newItem, reason);
}
- public UUID addSearch(final cgSearch search, final List<cgCache> cacheList, final boolean newItem, final int reason) {
+ public cgSearch addSearch(final cgSearch search, final List<cgCache> cacheList, final boolean newItem, final int reason) {
if (CollectionUtils.isEmpty(cacheList)) {
return null;
}
- final UUID searchId = search.getCurrentId();
- searches.put(searchId, search);
-
if (storage == null) {
storage = new cgData(this);
}
@@ -598,7 +560,7 @@ public class cgeoapplication extends Application {
}
}
- return searchId;
+ return search;
}
public boolean addCacheToSearch(cgSearch search, cgCache cache) {
@@ -606,12 +568,6 @@ public class cgeoapplication extends Application {
return false;
}
- final UUID searchId = search.getCurrentId();
-
- if (!searches.containsKey(searchId)) {
- searches.put(searchId, search);
- }
-
final boolean status = storeWithMerge(cache, cache.reason >= 1);
if (status) {
diff --git a/main/src/cgeo/geocaching/cgeocaches.java b/main/src/cgeo/geocaching/cgeocaches.java
index 17a3ac2..1e6ae7f 100644
--- a/main/src/cgeo/geocaching/cgeocaches.java
+++ b/main/src/cgeo/geocaching/cgeocaches.java
@@ -74,7 +74,6 @@ import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import java.util.UUID;
public class cgeocaches extends AbstractListActivity {
@@ -153,7 +152,7 @@ public class cgeocaches extends AbstractListActivity {
private String keyword = null;
private String address = null;
private String username = null;
- private UUID searchId = null;
+ private cgSearch search = null;
private List<cgCache> cacheList = new ArrayList<cgCache>();
private cgCacheListAdapter adapter = null;
private LayoutInflater inflater = null;
@@ -183,11 +182,11 @@ public class cgeocaches extends AbstractListActivity {
@Override
public void handleMessage(Message msg) {
try {
- if (searchId != null) {
- setTitle(title + " [" + app.getCount(searchId) + "]");
+ if (search != null) {
+ setTitle(title + " [" + cgeoapplication.getCount(search) + "]");
cacheList.clear();
- final List<cgCache> cacheListTmp = app.getCaches(searchId, false);
+ final List<cgCache> cacheListTmp = app.getCaches(search, false);
if (CollectionUtils.isNotEmpty(cacheListTmp)) {
cacheList.addAll(cacheListTmp);
cacheListTmp.clear();
@@ -204,10 +203,10 @@ public class cgeocaches extends AbstractListActivity {
showToast(res.getString(R.string.err_list_load_fail));
setMoreCaches(false);
} else {
- final Integer count = app.getTotal(searchId);
+ final Integer count = cgeoapplication.getTotal(search);
if (count != null && count > 0) {
- if (cacheList.size() < app.getTotal(searchId) && cacheList.size() < MAX_LIST_ITEMS) {
+ if (cacheList.size() < cgeoapplication.getTotal(search) && cacheList.size() < MAX_LIST_ITEMS) {
setMoreCaches(true);
} else {
setMoreCaches(false);
@@ -217,7 +216,7 @@ public class cgeocaches extends AbstractListActivity {
}
}
- if (cacheList != null && app.getError(searchId) == StatusCode.UNAPPROVED_LICENSE) {
+ if (cacheList != null && cgeoapplication.getError(search) == StatusCode.UNAPPROVED_LICENSE) {
AlertDialog.Builder dialog = new AlertDialog.Builder(cgeocaches.this);
dialog.setTitle(res.getString(R.string.license));
dialog.setMessage(res.getString(R.string.err_license));
@@ -239,8 +238,8 @@ public class cgeocaches extends AbstractListActivity {
AlertDialog alert = dialog.create();
alert.show();
- } else if (app != null && app.getError(searchId) != null) {
- showToast(res.getString(R.string.err_download_fail) + app.getError(searchId).getErrorString(res) + ".");
+ } else if (app != null && cgeoapplication.getError(search) != null) {
+ showToast(res.getString(R.string.err_download_fail) + cgeoapplication.getError(search).getErrorString(res) + ".");
hideLoading();
showProgress(false);
@@ -281,11 +280,11 @@ public class cgeocaches extends AbstractListActivity {
@Override
public void handleMessage(Message msg) {
try {
- if (searchId != null) {
- setTitle(title + " [" + app.getCount(searchId) + "]");
+ if (search != null) {
+ setTitle(title + " [" + cgeoapplication.getCount(search) + "]");
cacheList.clear();
- final List<cgCache> cacheListTmp = app.getCaches(searchId, false);
+ final List<cgCache> cacheListTmp = app.getCaches(search, false);
if (CollectionUtils.isNotEmpty(cacheListTmp)) {
cacheList.addAll(cacheListTmp);
cacheListTmp.clear();
@@ -304,9 +303,9 @@ public class cgeocaches extends AbstractListActivity {
showToast(res.getString(R.string.err_list_load_fail));
setMoreCaches(false);
} else {
- final Integer count = app.getTotal(searchId);
+ final Integer count = cgeoapplication.getTotal(search);
if (count != null && count > 0) {
- if (cacheList.size() < app.getTotal(searchId) && cacheList.size() < MAX_LIST_ITEMS) {
+ if (cacheList.size() < cgeoapplication.getTotal(search) && cacheList.size() < MAX_LIST_ITEMS) {
setMoreCaches(true);
} else {
setMoreCaches(false);
@@ -316,8 +315,8 @@ public class cgeocaches extends AbstractListActivity {
}
}
- if (app.getError(searchId) != null) {
- showToast(res.getString(R.string.err_download_fail) + app.getError(searchId).getErrorString(res) + ".");
+ if (cgeoapplication.getError(search) != null) {
+ showToast(res.getString(R.string.err_download_fail) + cgeoapplication.getError(search).getErrorString(res) + ".");
listFooter.setOnClickListener(new moreCachesListener());
hideLoading();
@@ -373,8 +372,8 @@ public class cgeocaches extends AbstractListActivity {
}
}
} else {
- if (cacheList != null && searchId != null) {
- final List<cgCache> cacheListTmp = app.getCaches(searchId, false);
+ if (cacheList != null && search != null) {
+ final List<cgCache> cacheListTmp = app.getCaches(search, false);
if (CollectionUtils.isNotEmpty(cacheListTmp)) {
cacheList.clear();
cacheList.addAll(cacheListTmp);
@@ -444,7 +443,7 @@ public class cgeocaches extends AbstractListActivity {
cacheList.clear();
- final List<cgCache> cacheListTmp = app.getCaches(searchId, false);
+ final List<cgCache> cacheListTmp = app.getCaches(search, false);
if (CollectionUtils.isNotEmpty(cacheListTmp)) {
cacheList.addAll(cacheListTmp);
cacheListTmp.clear();
@@ -472,7 +471,7 @@ public class cgeocaches extends AbstractListActivity {
cacheList.clear();
- final List<cgCache> cacheListTmp = app.getCaches(searchId, false);
+ final List<cgCache> cacheListTmp = app.getCaches(search, false);
if (CollectionUtils.isNotEmpty(cacheListTmp)) {
cacheList.addAll(cacheListTmp);
cacheListTmp.clear();
@@ -692,7 +691,7 @@ public class cgeocaches extends AbstractListActivity {
title = res.getString(R.string.map_map);
setTitle(title);
showProgress(true);
- searchId = (UUID) extras.get("searchId");
+ search = (cgSearch) extras.get("search");
loadCachesHandler.sendMessage(Message.obtain());
break;
default:
@@ -729,7 +728,7 @@ public class cgeocaches extends AbstractListActivity {
}
}
- if (loadCachesHandler != null && searchId != null) {
+ if (loadCachesHandler != null && search != null) {
loadCachesHandler.sendEmptyMessage(0);
}
}
@@ -1084,7 +1083,7 @@ public class cgeocaches extends AbstractListActivity {
return false;
}
- return CacheListAppFactory.onMenuItemSelected(item, geo, cacheList, this, res, searchId);
+ return CacheListAppFactory.onMenuItemSelected(item, geo, cacheList, this, res, search);
}
private void setComparator(MenuItem item,
@@ -1320,11 +1319,11 @@ public class cgeocaches extends AbstractListActivity {
lastMenuInfo = info;
if (cache != null) {
- // create a searchId for a single cache (as if in details view)
- final UUID singleSearchId = base.searchByGeocode(cache.geocode, null, 0, false, null);
+ // create a search for a single cache (as if in details view)
+ final cgSearch singleSearch = base.searchByGeocode(cache.geocode, null, 0, false, null);
if (NavigationAppFactory.onMenuItemSelected(item, geo, this,
- res, cache, singleSearchId, null, null)) {
+ res, cache, singleSearch, null, null)) {
return true;
}
@@ -1444,10 +1443,10 @@ public class cgeocaches extends AbstractListActivity {
}
if (CollectionUtils.isNotEmpty(cacheList)) {
- final Integer count = app.getTotal(searchId);
+ final Integer count = cgeoapplication.getTotal(search);
if (count != null && count > 0) {
setTitle(title);
- if (cacheList.size() < app.getTotal(searchId) && cacheList.size() < MAX_LIST_ITEMS) {
+ if (cacheList.size() < cgeoapplication.getTotal(search) && cacheList.size() < MAX_LIST_ITEMS) {
setMoreCaches(true);
} else {
setMoreCaches(false);
@@ -1802,9 +1801,9 @@ public class cgeocaches extends AbstractListActivity {
@Override
public void run() {
if (coords != null) {
- searchId = base.searchByOffline(coords, Settings.getCacheType(), listId);
+ search = base.searchByOffline(coords, Settings.getCacheType(), listId);
} else {
- searchId = base.searchByOffline(null, null, 1);
+ search = base.searchByOffline(null, null, 1);
}
handler.sendMessage(new Message());
}
@@ -1820,7 +1819,7 @@ public class cgeocaches extends AbstractListActivity {
@Override
public void run() {
- searchId = base.searchByHistory(coords != null ? Settings.getCacheType() : null);
+ search = base.searchByHistory(coords != null ? Settings.getCacheType() : null);
handler.sendMessage(new Message());
}
}
@@ -1835,7 +1834,7 @@ public class cgeocaches extends AbstractListActivity {
@Override
public void run() {
- searchId = base.searchByNextPage(this, searchId, 0, Settings.isShowCaptcha());
+ search = base.searchByNextPage(this, search, 0, Settings.isShowCaptcha());
handler.sendMessage(new Message());
}
@@ -1864,7 +1863,7 @@ public class cgeocaches extends AbstractListActivity {
@Override
public void run() {
- searchId = base.searchByCoords(this, coords, cachetype, 0, Settings.isShowCaptcha());
+ search = base.searchByCoords(this, coords, cachetype, 0, Settings.isShowCaptcha());
handler.sendMessage(new Message());
}
@@ -1893,7 +1892,7 @@ public class cgeocaches extends AbstractListActivity {
@Override
public void run() {
- searchId = base.searchByKeyword(this, keyword, cachetype, 0, Settings.isShowCaptcha());
+ search = base.searchByKeyword(this, keyword, cachetype, 0, Settings.isShowCaptcha());
handler.sendMessage(new Message());
}
}
@@ -1921,7 +1920,7 @@ public class cgeocaches extends AbstractListActivity {
@Override
public void run() {
- searchId = base.searchByUsername(this, username, cachetype, 0, Settings.isShowCaptcha());
+ search = base.searchByUsername(this, username, cachetype, 0, Settings.isShowCaptcha());
handler.sendMessage(new Message());
}
}
@@ -1953,7 +1952,7 @@ public class cgeocaches extends AbstractListActivity {
params.put("username", username);
params.put("cachetype", cachetype);
- searchId = base.searchByOwner(this, username, cachetype, 0, Settings.isShowCaptcha());
+ search = base.searchByOwner(this, username, cachetype, 0, Settings.isShowCaptcha());
handler.sendMessage(new Message());
}
@@ -2599,13 +2598,13 @@ public class cgeocaches extends AbstractListActivity {
* unused here but needed since this method is referenced from XML layout
*/
public void goMap(View view) {
- if (searchId == null || CollectionUtils.isEmpty(cacheList)) {
+ if (search == null || CollectionUtils.isEmpty(cacheList)) {
showToast(res.getString(R.string.warn_no_cache_coord));
return;
}
- CGeoMap.startActivitySearch(this, searchId, title + " [" + app.getCount(searchId) + "]", false);
+ CGeoMap.startActivitySearch(this, search, title + " [" + cgeoapplication.getCount(search) + "]", false);
}
public void goManual(View view) {
@@ -2724,10 +2723,10 @@ public class cgeocaches extends AbstractListActivity {
context.startActivity(cachesIntent);
}
- public static void startActivityMap(final Context context, final UUID uuid) {
+ public static void startActivityMap(final Context context, final cgSearch search) {
final Intent cachesIntent = new Intent(context, cgeocaches.class);
cachesIntent.putExtra(EXTRAS_LIST_TYPE, CacheListType.MAP);
- cachesIntent.putExtra("searchId", uuid);
+ cachesIntent.putExtra("search", search);
context.startActivity(cachesIntent);
}
diff --git a/main/src/cgeo/geocaching/cgeodetail.java b/main/src/cgeo/geocaching/cgeodetail.java
index dfb0e63..3ba3537 100644
--- a/main/src/cgeo/geocaching/cgeodetail.java
+++ b/main/src/cgeo/geocaching/cgeodetail.java
@@ -67,7 +67,6 @@ import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Map.Entry;
-import java.util.UUID;
/**
* Activity to display all details of a cache like owner, difficulty, description etc.
@@ -82,7 +81,7 @@ public class cgeodetail extends AbstractActivity {
super("c:geo-cache-details");
}
- public UUID searchId = null;
+ public cgSearch search = null;
public cgCache cache = null;
public String geocode = null;
public String name = null;
@@ -127,7 +126,7 @@ public class cgeodetail extends AbstractActivity {
storeThread = null;
try {
- cache = app.getCache(searchId); // reload cache details
+ cache = app.getCache(search); // reload cache details
} catch (Exception e) {
showToast(res.getString(R.string.err_store_failed));
@@ -144,7 +143,7 @@ public class cgeodetail extends AbstractActivity {
refreshThread = null;
try {
- cache = app.getCache(searchId); // reload cache details
+ cache = app.getCache(search); // reload cache details
} catch (Exception e) {
showToast(res.getString(R.string.err_refresh_failed));
@@ -159,7 +158,7 @@ public class cgeodetail extends AbstractActivity {
@Override
public void handleMessage(Message msg) {
try {
- cache = app.getCache(searchId); // reload cache details
+ cache = app.getCache(search); // reload cache details
} catch (Exception e) {
showToast(res.getString(R.string.err_drop_failed));
@@ -176,15 +175,15 @@ public class cgeodetail extends AbstractActivity {
if (cgBase.UPDATE_LOAD_PROGRESS_DETAIL == msg.what && msg.obj instanceof String) {
updateStatusMsg((String) msg.obj);
} else {
- if (searchId == null) {
+ if (search == null) {
showToast(res.getString(R.string.err_dwld_details_failed));
finish();
return;
}
- if (app.getError(searchId) != null) {
- showToast(res.getString(R.string.err_dwld_details_failed_reason) + " " + app.getError(searchId) + ".");
+ if (cgeoapplication.getError(search) != null) {
+ showToast(res.getString(R.string.err_dwld_details_failed_reason) + " " + cgeoapplication.getError(search) + ".");
finish();
return;
@@ -636,7 +635,7 @@ public class cgeodetail extends AbstractActivity {
}
return false;
}
- if (NavigationAppFactory.onMenuItemSelected(item, geo, this, res, cache, searchId, null, null)) {
+ if (NavigationAppFactory.onMenuItemSelected(item, geo, this, res, cache, search, null, null)) {
return true;
}
if (GeneralAppsFactory.onMenuItemSelected(item, this, cache)) {
@@ -659,8 +658,8 @@ public class cgeodetail extends AbstractActivity {
geo = app.startGeo(this, geoUpdate, base, 0, 0);
}
- if (searchId != null) {
- cache = app.getCache(searchId);
+ if (search != null) {
+ cache = app.getCache(search);
if (cache != null && cache.geocode != null) {
geocode = cache.geocode;
}
@@ -676,11 +675,11 @@ public class cgeodetail extends AbstractActivity {
TextView itemName;
TextView itemValue;
- if (searchId == null) {
+ if (search == null) {
return;
}
- cache = app.getCache(searchId);
+ cache = app.getCache(search);
if (cache == null) {
progress.dismiss();
@@ -1380,7 +1379,7 @@ public class cgeodetail extends AbstractActivity {
if (StringUtils.isBlank(geocode) && StringUtils.isBlank(guid)) {
return;
}
- searchId = base.searchByGeocode(geocode, StringUtils.isBlank(geocode) ? guid : null, 0, false, handler);
+ search = base.searchByGeocode(geocode, StringUtils.isBlank(geocode) ? guid : null, 0, false, handler);
handler.sendMessage(new Message());
}
}
@@ -1772,7 +1771,7 @@ public class cgeodetail extends AbstractActivity {
@Override
public void run() {
app.removeCacheFromCache(geocode);
- searchId = base.searchByGeocode(cache.geocode, null, 0, true, null);
+ search = base.searchByGeocode(cache.geocode, null, 0, true, null);
handler.sendEmptyMessage(0);
}
diff --git a/main/src/cgeo/geocaching/cgeogpxes.java b/main/src/cgeo/geocaching/cgeogpxes.java
index 4714049..865b9e7 100644
--- a/main/src/cgeo/geocaching/cgeogpxes.java
+++ b/main/src/cgeo/geocaching/cgeogpxes.java
@@ -20,7 +20,6 @@ import java.io.File;
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.util.List;
-import java.util.UUID;
public class cgeogpxes extends FileList<cgGPXListAdapter> {
@@ -135,11 +134,11 @@ public class cgeogpxes extends FileList<cgGPXListAdapter> {
@Override
public void run() {
- final UUID searchId = doImport();
- loadCachesHandler.sendMessage(loadCachesHandler.obtainMessage(0, app.getCount(searchId), 0));
+ final cgSearch search = doImport();
+ loadCachesHandler.sendMessage(loadCachesHandler.obtainMessage(0, cgeoapplication.getCount(search), 0));
}
- protected abstract UUID doImport();
+ protected abstract cgSearch doImport();
}
private class ImportFileThread extends ImportThread {
@@ -150,7 +149,7 @@ public class cgeogpxes extends FileList<cgGPXListAdapter> {
}
@Override
- protected UUID doImport() {
+ protected cgSearch doImport() {
if (StringUtils.endsWithIgnoreCase(file.getName(), GPXParser.GPX_FILE_EXTENSION)) {
return GPXParser.importGPX(file, listId, changeParseDialogHandler);
}
@@ -168,7 +167,7 @@ public class cgeogpxes extends FileList<cgGPXListAdapter> {
}
@Override
- protected UUID doImport() {
+ protected cgSearch doImport() {
return GPXParser.importGPX(stream, listId, changeParseDialogHandler);
}
}
diff --git a/main/src/cgeo/geocaching/connector/AbstractConnector.java b/main/src/cgeo/geocaching/connector/AbstractConnector.java
index 1a3048a..4153c76 100644
--- a/main/src/cgeo/geocaching/connector/AbstractConnector.java
+++ b/main/src/cgeo/geocaching/connector/AbstractConnector.java
@@ -7,8 +7,6 @@ import cgeo.geocaching.cgeoapplication;
import android.os.Handler;
-import java.util.UUID;
-
public abstract class AbstractConnector implements IConnector {
@Override
@@ -47,7 +45,7 @@ public abstract class AbstractConnector implements IConnector {
}
@Override
- public UUID searchByGeocode(cgBase base, String geocode, String guid, cgeoapplication app, cgSearch search, int reason, Handler handler) {
+ public cgSearch searchByGeocode(cgBase base, String geocode, String guid, cgeoapplication app, cgSearch search, int reason, Handler handler) {
return null;
}
diff --git a/main/src/cgeo/geocaching/connector/GCConnector.java b/main/src/cgeo/geocaching/connector/GCConnector.java
index 05c0218..51dca6d 100644
--- a/main/src/cgeo/geocaching/connector/GCConnector.java
+++ b/main/src/cgeo/geocaching/connector/GCConnector.java
@@ -17,7 +17,6 @@ import android.util.Log;
import java.util.ArrayList;
import java.util.List;
-import java.util.UUID;
public class GCConnector extends AbstractConnector implements IConnector {
@@ -68,7 +67,7 @@ public class GCConnector extends AbstractConnector implements IConnector {
}
@Override
- public UUID searchByGeocode(final cgBase base, String geocode, final String guid, final cgeoapplication app, final cgSearch search, final int reason, final Handler handler) {
+ public cgSearch searchByGeocode(final cgBase base, String geocode, final String guid, final cgeoapplication app, final cgSearch search, final int reason, final Handler handler) {
final Parameters params = new Parameters("decrypt", "y");
if (StringUtils.isNotBlank(geocode)) {
params.put("wp", geocode);
@@ -102,7 +101,7 @@ public class GCConnector extends AbstractConnector implements IConnector {
cacheList.clear();
- return search.getCurrentId();
+ return search;
}
Log.e(Settings.tag, "cgeoBase.searchByGeocode: No data from server");
@@ -128,6 +127,6 @@ public class GCConnector extends AbstractConnector implements IConnector {
final List<cgCache> cacheList = cgBase.filterSearchResults(search, caches, false, false, null);
app.addSearch(search, cacheList, true, reason);
- return search.getCurrentId();
+ return search;
}
}
diff --git a/main/src/cgeo/geocaching/connector/IConnector.java b/main/src/cgeo/geocaching/connector/IConnector.java
index 68c9db6..54962bb 100644
--- a/main/src/cgeo/geocaching/connector/IConnector.java
+++ b/main/src/cgeo/geocaching/connector/IConnector.java
@@ -7,8 +7,6 @@ import cgeo.geocaching.cgeoapplication;
import android.os.Handler;
-import java.util.UUID;
-
public interface IConnector {
/**
* get name for display (currently only used in links)
@@ -78,5 +76,5 @@ public interface IConnector {
*/
public boolean supportsCachesAround();
- public UUID searchByGeocode(final cgBase base, final String geocode, final String guid, final cgeoapplication app, final cgSearch search, final int reason, final Handler handler);
+ public cgSearch searchByGeocode(final cgBase base, final String geocode, final String guid, final cgeoapplication app, final cgSearch search, final int reason, final Handler handler);
}
diff --git a/main/src/cgeo/geocaching/connector/opencaching/ApiOpenCachingConnector.java b/main/src/cgeo/geocaching/connector/opencaching/ApiOpenCachingConnector.java
index 6334973..3c193d9 100644
--- a/main/src/cgeo/geocaching/connector/opencaching/ApiOpenCachingConnector.java
+++ b/main/src/cgeo/geocaching/connector/opencaching/ApiOpenCachingConnector.java
@@ -12,7 +12,6 @@ import cgeo.geocaching.utils.CryptUtils;
import android.os.Handler;
import java.util.List;
-import java.util.UUID;
public class ApiOpenCachingConnector extends OpenCachingConnector implements IConnector {
@@ -39,7 +38,7 @@ public class ApiOpenCachingConnector extends OpenCachingConnector implements ICo
}
@Override
- public UUID searchByGeocode(final cgBase base, final String geocode, final String guid, final cgeoapplication app, final cgSearch search, final int reason, final Handler handler) {
+ public cgSearch searchByGeocode(final cgBase base, final String geocode, final String guid, final cgeoapplication app, final cgSearch search, final int reason, final Handler handler) {
final cgCache cache = OkapiClient.getCache(geocode);
if (cache == null) {
return null;
@@ -50,6 +49,6 @@ public class ApiOpenCachingConnector extends OpenCachingConnector implements ICo
final List<cgCache> cacheList = cgBase.filterSearchResults(search, caches, false, false, null);
app.addSearch(search, cacheList, true, reason);
- return search.getCurrentId();
+ return search;
}
}
diff --git a/main/src/cgeo/geocaching/files/GPXParser.java b/main/src/cgeo/geocaching/files/GPXParser.java
index 5b4f7de..9d95f90 100644
--- a/main/src/cgeo/geocaching/files/GPXParser.java
+++ b/main/src/cgeo/geocaching/files/GPXParser.java
@@ -41,7 +41,6 @@ import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
-import java.util.UUID;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -870,7 +869,7 @@ public abstract class GPXParser extends FileParser {
}
}
- public static UUID importGPX(File file, int listId, Handler handler) {
+ public static cgSearch importGPX(File file, int listId, Handler handler) {
try {
// parse cache file
GPXParser parser = new GPX10Parser(listId);
@@ -899,7 +898,7 @@ public abstract class GPXParser extends FileParser {
return null;
}
- public static UUID importGPX(InputStream stream, int listId, Handler handler) {
+ public static cgSearch importGPX(InputStream stream, int listId, Handler handler) {
try {
// parse cache file
GPXParser parser = new GPX10Parser(listId);
@@ -920,7 +919,7 @@ public abstract class GPXParser extends FileParser {
return null;
}
- private static UUID storeParsedCaches(Handler handler, GPXParser parser) {
+ private static cgSearch storeParsedCaches(Handler handler, GPXParser parser) {
final cgSearch search = new cgSearch();
final cgeoapplication app = cgeoapplication.getInstance();
int storedCaches = 0;
@@ -931,7 +930,7 @@ public abstract class GPXParser extends FileParser {
showCountMessage(handler, R.string.gpx_import_storing, ++storedCaches);
}
Log.i(Settings.tag, "Caches found in .gpx file: " + parser.getParsedCaches().size());
- return search.getCurrentId();
+ return search;
}
// 1234567.gpx -> 1234567-wpts.gpx
diff --git a/main/src/cgeo/geocaching/files/LocParser.java b/main/src/cgeo/geocaching/files/LocParser.java
index ddd368a..ba86dc4 100644
--- a/main/src/cgeo/geocaching/files/LocParser.java
+++ b/main/src/cgeo/geocaching/files/LocParser.java
@@ -20,7 +20,6 @@ import java.io.File;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
-import java.util.UUID;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -140,7 +139,7 @@ public final class LocParser extends FileParser {
return coords;
}
- public static UUID parseLoc(File file, int listId,
+ public static cgSearch parseLoc(File file, int listId,
Handler handler) {
final cgSearch search = new cgSearch();
@@ -170,6 +169,6 @@ public final class LocParser extends FileParser {
Log.e(Settings.tag, "LocParser.parseLoc: " + e.toString());
}
- return search.getCurrentId();
+ return search;
}
}
diff --git a/main/src/cgeo/geocaching/maps/CGeoMap.java b/main/src/cgeo/geocaching/maps/CGeoMap.java
index 6f85027..4c693a6 100644
--- a/main/src/cgeo/geocaching/maps/CGeoMap.java
+++ b/main/src/cgeo/geocaching/maps/CGeoMap.java
@@ -59,7 +59,6 @@ import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
-import java.util.UUID;
/**
* Class representing the Map in c:geo
@@ -71,7 +70,7 @@ public class CGeoMap extends AbstractMap implements OnDragListener, ViewFactory
private static final String EXTRAS_LATITUDE = "latitude";
private static final String EXTRAS_WPTTYPE = "wpttype";
private static final String EXTRAS_MAPSTATE = "mapstate";
- private static final String EXTRAS_SEARCHID = "searchid";
+ private static final String EXTRAS_SEARCH = "search";
private static final String EXTRAS_DETAIL = "detail";
private static final int MENU_SELECT_MAPVIEW = 1;
private static final int MENU_MAP_LIVE = 2;
@@ -101,13 +100,13 @@ public class CGeoMap extends AbstractMap implements OnDragListener, ViewFactory
private cgUpdateDir dirUpdate = new UpdateDir();
// from intent
private boolean fromDetailIntent = false;
- private String searchIdIntent = null;
+ private cgSearch searchIntent = null;
private String geocodeIntent = null;
private Geopoint coordsIntent = null;
private WaypointType waypointTypeIntent = null;
private int[] mapStateIntent = null;
// status data
- private UUID searchId = null;
+ private cgSearch search = null;
private String token = null;
private boolean noMapTokenShowed = false;
// map status data
@@ -339,7 +338,7 @@ public class CGeoMap extends AbstractMap implements OnDragListener, ViewFactory
Bundle extras = activity.getIntent().getExtras();
if (extras != null) {
fromDetailIntent = extras.getBoolean(EXTRAS_DETAIL);
- searchIdIntent = extras.getString(EXTRAS_SEARCHID);
+ searchIntent = (cgSearch) extras.getParcelable(EXTRAS_SEARCH);
geocodeIntent = extras.getString(EXTRAS_GEOCODE);
final double latitudeIntent = extras.getDouble(EXTRAS_LATITUDE);
final double longitudeIntent = extras.getDouble(EXTRAS_LONGITUDE);
@@ -348,9 +347,6 @@ public class CGeoMap extends AbstractMap implements OnDragListener, ViewFactory
mapStateIntent = extras.getIntArray(EXTRAS_MAPSTATE);
mapTitle = extras.getString(EXTRAS_MAP_TITLE);
- if ("".equals(searchIdIntent)) {
- searchIdIntent = null;
- }
if (coordsIntent.getLatitude() == 0.0 || coordsIntent.getLongitude() == 0.0) {
coordsIntent = null;
}
@@ -361,15 +357,15 @@ public class CGeoMap extends AbstractMap implements OnDragListener, ViewFactory
}
// live map, if no arguments are given
- live = (searchIdIntent == null && geocodeIntent == null && coordsIntent == null);
+ live = (searchIntent == null && geocodeIntent == null && coordsIntent == null);
if (null == mapStateIntent) {
followMyLocation = live;
} else {
followMyLocation = 1 == mapStateIntent[3] ? true : false;
}
- if (geocodeIntent != null || searchIdIntent != null || coordsIntent != null || mapStateIntent != null) {
- centerMap(geocodeIntent, searchIdIntent, coordsIntent, mapStateIntent);
+ if (geocodeIntent != null || searchIntent != null || coordsIntent != null || mapStateIntent != null) {
+ centerMap(geocodeIntent, searchIntent, coordsIntent, mapStateIntent);
}
// prepare my location button
@@ -551,7 +547,7 @@ public class CGeoMap extends AbstractMap implements OnDragListener, ViewFactory
item.setTitle(res.getString(R.string.map_live_enable));
}
- menu.findItem(MENU_STORE_CACHES).setEnabled(live && !isLoading() && CollectionUtils.isNotEmpty(caches) && app.hasUnsavedCaches(searchId));
+ menu.findItem(MENU_STORE_CACHES).setEnabled(live && !isLoading() && CollectionUtils.isNotEmpty(caches) && app.hasUnsavedCaches(search));
item = menu.findItem(MENU_CIRCLE_MODE); // show circles
if (overlayCaches != null && overlayCaches.getCircles()) {
@@ -584,8 +580,8 @@ public class CGeoMap extends AbstractMap implements OnDragListener, ViewFactory
case MENU_MAP_LIVE:
Settings.setLiveMap(!Settings.isLiveMap());
liveChanged = true;
- searchId = null;
- searchIdIntent = null;
+ search = null;
+ searchIntent = null;
return true;
case MENU_STORE_CACHES:
if (live && !isLoading() && CollectionUtils.isNotEmpty(caches)) {
@@ -669,7 +665,7 @@ public class CGeoMap extends AbstractMap implements OnDragListener, ViewFactory
overlayCaches.switchCircles();
mapView.invalidate();
return true;
- case MENU_AS_LIST:
+ case MENU_AS_LIST: {
final cgSearch search = new cgSearch();
search.totalCnt = caches.size();
for (cgCache cache : caches) {
@@ -677,6 +673,7 @@ public class CGeoMap extends AbstractMap implements OnDragListener, ViewFactory
}
cgeocaches.startActivityMap(activity, app.addSearch(search, caches, true, 0));
return true;
+ }
default:
if (SUBMENU_VIEW_GOOGLE_MAP <= id && SUBMENU_VIEW_MF_OFFLINE >= id) {
item.setChecked(true);
@@ -692,7 +689,7 @@ public class CGeoMap extends AbstractMap implements OnDragListener, ViewFactory
Intent mapIntent = new Intent(activity, Settings.getMapFactory().getMapClass());
mapIntent.putExtra(EXTRAS_DETAIL, fromDetailIntent);
- mapIntent.putExtra(EXTRAS_SEARCHID, searchIdIntent);
+ mapIntent.putExtra(EXTRAS_SEARCH, searchIntent);
mapIntent.putExtra(EXTRAS_GEOCODE, geocodeIntent);
if (coordsIntent != null) {
mapIntent.putExtra(EXTRAS_LATITUDE, coordsIntent.getLatitude());
@@ -713,9 +710,8 @@ public class CGeoMap extends AbstractMap implements OnDragListener, ViewFactory
}
return true;
- }
- else {
- NavigationAppFactory.onMenuItemSelected(item, geo, activity, res, caches != null && caches.size() > 0 ? caches.get(0) : null, searchId, null, coordsIntent);
+ } else {
+ NavigationAppFactory.onMenuItemSelected(item, geo, activity, res, caches != null && caches.size() > 0 ? caches.get(0) : null, search, null, coordsIntent);
}
break;
}
@@ -1118,17 +1114,17 @@ public class CGeoMap extends AbstractMap implements OnDragListener, ViewFactory
// stage 1 - pull and render from the DB only
- if (fromDetailIntent || StringUtils.isNotEmpty(searchIdIntent)) {
- searchId = UUID.fromString(searchIdIntent);
+ if (fromDetailIntent || searchIntent != null) {
+ search = searchIntent;
} else {
if (!live || !Settings.isLiveMap()) {
- searchId = app.getStoredInViewport(centerLat, centerLon, spanLat, spanLon, Settings.getCacheType());
+ search = app.getStoredInViewport(centerLat, centerLon, spanLat, spanLon, Settings.getCacheType());
} else {
- searchId = app.getCachedInViewport(centerLat, centerLon, spanLat, spanLon, Settings.getCacheType());
+ search = app.getCachedInViewport(centerLat, centerLon, spanLat, spanLon, Settings.getCacheType());
}
}
- if (searchId != null) {
+ if (search != null) {
downloaded = true;
}
@@ -1139,7 +1135,7 @@ public class CGeoMap extends AbstractMap implements OnDragListener, ViewFactory
return;
}
- caches = app.getCaches(searchId, true);
+ caches = app.getCaches(search, true);
//if in live map and stored caches are found / disables are also shown.
if (live && Settings.isLiveMap()) {
@@ -1245,8 +1241,8 @@ public class CGeoMap extends AbstractMap implements OnDragListener, ViewFactory
return;
}
- searchId = base.searchByViewport(token, latMin, latMax, lonMin, lonMax, 0);
- if (searchId != null) {
+ search = base.searchByViewport(token, latMin, latMax, lonMin, lonMax, 0);
+ if (search != null) {
downloaded = true;
}
@@ -1259,7 +1255,7 @@ public class CGeoMap extends AbstractMap implements OnDragListener, ViewFactory
//TODO Portree Only overwrite if we got some. Otherwise maybe error icon
//TODO Merge not to show locally found caches
- caches = app.getCaches(searchId, centerLat, centerLon, spanLat, spanLon);
+ caches = app.getCaches(search, centerLat, centerLon, spanLat, spanLon);
if (stop) {
displayHandler.sendEmptyMessage(0);
@@ -1731,8 +1727,8 @@ public class CGeoMap extends AbstractMap implements OnDragListener, ViewFactory
}
}
- // move map to view results of searchIdIntent
- private void centerMap(String geocodeCenter, String searchIdCenter, final Geopoint coordsCenter, int[] mapState) {
+ // move map to view results of searchIntent
+ private void centerMap(String geocodeCenter, final cgSearch searchCenter, final Geopoint coordsCenter, int[] mapState) {
if (!centered && mapState != null) {
try {
@@ -1744,14 +1740,14 @@ public class CGeoMap extends AbstractMap implements OnDragListener, ViewFactory
centered = true;
alreadyCentered = true;
- } else if (!centered && (geocodeCenter != null || searchIdIntent != null)) {
+ } else if (!centered && (geocodeCenter != null || searchIntent != null)) {
try {
List<Object> viewport = null;
if (geocodeCenter != null) {
viewport = app.getBounds(geocodeCenter);
} else {
- viewport = app.getBounds(UUID.fromString(searchIdCenter));
+ viewport = app.getBounds(searchCenter);
}
if (viewport == null) {
@@ -1868,10 +1864,10 @@ public class CGeoMap extends AbstractMap implements OnDragListener, ViewFactory
return imageView;
}
- public static void startActivitySearch(final Activity fromActivity, final UUID searchId, final String title, boolean detail) {
+ public static void startActivitySearch(final Activity fromActivity, final cgSearch search, final String title, boolean detail) {
Intent mapIntent = new Intent(fromActivity, Settings.getMapFactory().getMapClass());
mapIntent.putExtra(EXTRAS_DETAIL, detail);
- mapIntent.putExtra(EXTRAS_SEARCHID, searchId.toString());
+ mapIntent.putExtra(EXTRAS_SEARCH, search);
if (StringUtils.isNotBlank(title)) {
mapIntent.putExtra(CGeoMap.EXTRAS_MAP_TITLE, title);
}
diff --git a/tests/src/cgeo/geocaching/cgeoApplicationTest.java b/tests/src/cgeo/geocaching/cgeoApplicationTest.java
index 20743f1..9c63261 100644
--- a/tests/src/cgeo/geocaching/cgeoApplicationTest.java
+++ b/tests/src/cgeo/geocaching/cgeoApplicationTest.java
@@ -9,7 +9,6 @@ import android.test.suitebuilder.annotation.SmallTest;
import java.util.Date;
import java.util.HashMap;
-import java.util.UUID;
import junit.framework.Assert;
@@ -54,8 +53,8 @@ public class cgeoApplicationTest extends ApplicationTestCase<cgeoapplication> {
*/
@MediumTest
public void testSearchByGeocode() {
- final UUID id = base.searchByGeocode("GC1RMM2", null, 0, true, null);
- Assert.assertNotNull(id);
+ final cgSearch search = base.searchByGeocode("GC1RMM2", null, 0, true, null);
+ Assert.assertNotNull(search);
}
/**