aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSamuel Tardieu <sam@rfc1149.net>2011-09-06 05:45:53 +0200
committerSamuel Tardieu <sam@rfc1149.net>2011-09-06 06:05:23 +0200
commitd62197ccda7b6a79bbdd0950b297236b750abe67 (patch)
tree0af82d6d2c8fed591be5b1d7fe181059a5d420b8 /src
parentede2a9cd6d6b1943aa6a94fd984de0ef3692b6bc (diff)
downloadcgeo-d62197ccda7b6a79bbdd0950b297236b750abe67.zip
cgeo-d62197ccda7b6a79bbdd0950b297236b750abe67.tar.gz
cgeo-d62197ccda7b6a79bbdd0950b297236b750abe67.tar.bz2
Use UUID instead of Long as a unique id
The previously used id was not necessarily unique. The UUID class in java.util has been designed for this purpose.
Diffstat (limited to 'src')
-rw-r--r--src/cgeo/geocaching/apps/cache/navi/GoogleMapsApp.java4
-rw-r--r--src/cgeo/geocaching/apps/cache/navi/GoogleNavigationApp.java4
-rw-r--r--src/cgeo/geocaching/apps/cache/navi/InternalMap.java6
-rw-r--r--src/cgeo/geocaching/apps/cache/navi/LocusApp.java3
-rw-r--r--src/cgeo/geocaching/apps/cache/navi/NavigationApp.java4
-rw-r--r--src/cgeo/geocaching/apps/cache/navi/NavigationAppFactory.java3
-rw-r--r--src/cgeo/geocaching/apps/cache/navi/RMapsApp.java3
-rw-r--r--src/cgeo/geocaching/apps/cache/navi/RadarApp.java4
-rw-r--r--src/cgeo/geocaching/apps/cache/navi/StaticMapApp.java4
-rw-r--r--src/cgeo/geocaching/apps/cache/navi/StreetviewApp.java4
-rw-r--r--src/cgeo/geocaching/apps/cachelist/CacheListApp.java3
-rw-r--r--src/cgeo/geocaching/apps/cachelist/CacheListAppFactory.java3
-rw-r--r--src/cgeo/geocaching/apps/cachelist/InternalCacheListMap.java5
-rw-r--r--src/cgeo/geocaching/apps/cachelist/LocusCacheListApp.java3
-rw-r--r--src/cgeo/geocaching/cgBase.java23
-rw-r--r--src/cgeo/geocaching/cgSearch.java7
-rw-r--r--src/cgeo/geocaching/cgeoapplication.java49
-rw-r--r--src/cgeo/geocaching/cgeocaches.java13
-rw-r--r--src/cgeo/geocaching/cgeodetail.java7
-rw-r--r--src/cgeo/geocaching/cgeogpxes.java3
-rw-r--r--src/cgeo/geocaching/files/GPXParser.java17
-rw-r--r--src/cgeo/geocaching/files/LocParser.java5
-rw-r--r--src/cgeo/geocaching/mapcommon/cgeomap.java15
23 files changed, 111 insertions, 81 deletions
diff --git a/src/cgeo/geocaching/apps/cache/navi/GoogleMapsApp.java b/src/cgeo/geocaching/apps/cache/navi/GoogleMapsApp.java
index 6b05426..273be5c 100644
--- a/src/cgeo/geocaching/apps/cache/navi/GoogleMapsApp.java
+++ b/src/cgeo/geocaching/apps/cache/navi/GoogleMapsApp.java
@@ -1,5 +1,7 @@
package cgeo.geocaching.apps.cache.navi;
+import java.util.UUID;
+
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
@@ -26,7 +28,7 @@ class GoogleMapsApp extends AbstractNavigationApp implements NavigationApp {
public boolean invoke(cgGeo geo, Activity activity, Resources res,
cgCache cache,
- Long searchId, cgWaypoint waypoint, Double latitude, Double longitude) {
+ final UUID searchId, cgWaypoint waypoint, Double latitude, Double longitude) {
if (cache == null && waypoint == null && latitude == null && longitude == null) {
return false;
}
diff --git a/src/cgeo/geocaching/apps/cache/navi/GoogleNavigationApp.java b/src/cgeo/geocaching/apps/cache/navi/GoogleNavigationApp.java
index b8afb54..4a7a49e 100644
--- a/src/cgeo/geocaching/apps/cache/navi/GoogleNavigationApp.java
+++ b/src/cgeo/geocaching/apps/cache/navi/GoogleNavigationApp.java
@@ -1,5 +1,7 @@
package cgeo.geocaching.apps.cache.navi;
+import java.util.UUID;
+
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
@@ -28,7 +30,7 @@ class GoogleNavigationApp extends AbstractNavigationApp implements
@Override
public boolean invoke(final cgGeo geo, final Activity activity, final Resources res,
final cgCache cache,
- final Long searchId, final cgWaypoint waypoint, final Double latitude, final Double longitude) {
+ final UUID searchId, final cgWaypoint waypoint, final Double latitude, final Double longitude) {
if (activity == null) {
return false;
}
diff --git a/src/cgeo/geocaching/apps/cache/navi/InternalMap.java b/src/cgeo/geocaching/apps/cache/navi/InternalMap.java
index 4c3d815..513172c 100644
--- a/src/cgeo/geocaching/apps/cache/navi/InternalMap.java
+++ b/src/cgeo/geocaching/apps/cache/navi/InternalMap.java
@@ -1,5 +1,7 @@
package cgeo.geocaching.apps.cache.navi;
+import java.util.UUID;
+
import android.app.Activity;
import android.content.Intent;
import android.content.res.Resources;
@@ -19,7 +21,7 @@ class InternalMap extends AbstractInternalMap implements
@Override
public boolean invoke(cgGeo geo, Activity activity, Resources res,
cgCache cache,
- Long searchId, cgWaypoint waypoint, Double latitude, Double longitude) {
+ final UUID searchId, cgWaypoint waypoint, Double latitude, Double longitude) {
cgSettings settings = getSettings(activity);
Intent mapIntent = new Intent(activity, settings.getMapFactory().getMapClass());
if (cache != null) {
@@ -28,7 +30,7 @@ class InternalMap extends AbstractInternalMap implements
}
if (searchId != null) {
mapIntent.putExtra("detail", true);
- mapIntent.putExtra("searchid", searchId);
+ mapIntent.putExtra("searchid", searchId.toString());
}
if (waypoint != null) {
mapIntent.putExtra("latitude", waypoint.latitude);
diff --git a/src/cgeo/geocaching/apps/cache/navi/LocusApp.java b/src/cgeo/geocaching/apps/cache/navi/LocusApp.java
index 80c7052..fdba2fc 100644
--- a/src/cgeo/geocaching/apps/cache/navi/LocusApp.java
+++ b/src/cgeo/geocaching/apps/cache/navi/LocusApp.java
@@ -4,6 +4,7 @@ import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.util.ArrayList;
import java.util.List;
+import java.util.UUID;
import org.apache.commons.lang3.StringUtils;
@@ -29,7 +30,7 @@ class LocusApp extends AbstractLocusApp implements NavigationApp {
@Override
public boolean invoke(cgGeo geo, Activity activity, Resources res,
cgCache cache,
- Long searchId, cgWaypoint waypoint, Double latitude, Double longitude) {
+ final UUID searchId, cgWaypoint waypoint, Double latitude, Double longitude) {
if (cache == null && waypoint == null && latitude == null
&& longitude == null) {
return false;
diff --git a/src/cgeo/geocaching/apps/cache/navi/NavigationApp.java b/src/cgeo/geocaching/apps/cache/navi/NavigationApp.java
index 2f52111..db0c1e3 100644
--- a/src/cgeo/geocaching/apps/cache/navi/NavigationApp.java
+++ b/src/cgeo/geocaching/apps/cache/navi/NavigationApp.java
@@ -1,5 +1,7 @@
package cgeo.geocaching.apps.cache.navi;
+import java.util.UUID;
+
import android.app.Activity;
import android.content.res.Resources;
import cgeo.geocaching.cgCache;
@@ -11,6 +13,6 @@ interface NavigationApp extends App {
public boolean invoke(final cgGeo geo, final Activity activity,
final Resources res,
final cgCache cache,
- final Long searchId, final cgWaypoint waypoint,
+ final UUID searchId, final cgWaypoint waypoint,
final Double latitude, final Double longitude);
}
diff --git a/src/cgeo/geocaching/apps/cache/navi/NavigationAppFactory.java b/src/cgeo/geocaching/apps/cache/navi/NavigationAppFactory.java
index 1ee5c87..b8872e3 100644
--- a/src/cgeo/geocaching/apps/cache/navi/NavigationAppFactory.java
+++ b/src/cgeo/geocaching/apps/cache/navi/NavigationAppFactory.java
@@ -1,6 +1,7 @@
package cgeo.geocaching.apps.cache.navi;
import java.util.List;
+import java.util.UUID;
import org.apache.commons.lang3.ArrayUtils;
@@ -46,7 +47,7 @@ public final class NavigationAppFactory extends AbstractAppFactory {
public static boolean onMenuItemSelected(final MenuItem item,
final cgGeo geo, Activity activity, Resources res,
cgCache cache,
- Long searchId, cgWaypoint waypoint, List<Double> destination) {
+ final UUID searchId, cgWaypoint waypoint, List<Double> destination) {
NavigationApp app = (NavigationApp) getAppFromMenuItem(item, apps);
if (app != null) {
Double latitude = null;
diff --git a/src/cgeo/geocaching/apps/cache/navi/RMapsApp.java b/src/cgeo/geocaching/apps/cache/navi/RMapsApp.java
index 80802ac..8e75aaa 100644
--- a/src/cgeo/geocaching/apps/cache/navi/RMapsApp.java
+++ b/src/cgeo/geocaching/apps/cache/navi/RMapsApp.java
@@ -2,6 +2,7 @@ package cgeo.geocaching.apps.cache.navi;
import java.util.ArrayList;
import java.util.Locale;
+import java.util.UUID;
import android.app.Activity;
import android.content.Intent;
@@ -22,7 +23,7 @@ class RMapsApp extends AbstractNavigationApp implements NavigationApp {
@Override
public boolean invoke(cgGeo geo, Activity activity, Resources res,
cgCache cache,
- Long searchId, cgWaypoint waypoint, Double latitude, Double longitude) {
+ final UUID searchId, cgWaypoint waypoint, Double latitude, Double longitude) {
if (cache == null && waypoint == null && latitude == null
&& longitude == null) {
return false;
diff --git a/src/cgeo/geocaching/apps/cache/navi/RadarApp.java b/src/cgeo/geocaching/apps/cache/navi/RadarApp.java
index a4aec8c..7dc7676 100644
--- a/src/cgeo/geocaching/apps/cache/navi/RadarApp.java
+++ b/src/cgeo/geocaching/apps/cache/navi/RadarApp.java
@@ -1,5 +1,7 @@
package cgeo.geocaching.apps.cache.navi;
+import java.util.UUID;
+
import android.app.Activity;
import android.content.Intent;
import android.content.res.Resources;
@@ -27,7 +29,7 @@ class RadarApp extends AbstractNavigationApp implements NavigationApp {
@Override
public boolean invoke(cgGeo geo, Activity activity, Resources res,
cgCache cache,
- Long searchId, cgWaypoint waypoint, Double latitude, Double longitude) {
+ final UUID searchId, cgWaypoint waypoint, Double latitude, Double longitude) {
if (cache != null) {
if (cache.latitude != null && cache.longitude != null) {
navigateTo(activity, cache.latitude, cache.longitude);
diff --git a/src/cgeo/geocaching/apps/cache/navi/StaticMapApp.java b/src/cgeo/geocaching/apps/cache/navi/StaticMapApp.java
index b6ae8c1..db6b27b 100644
--- a/src/cgeo/geocaching/apps/cache/navi/StaticMapApp.java
+++ b/src/cgeo/geocaching/apps/cache/navi/StaticMapApp.java
@@ -1,5 +1,7 @@
package cgeo.geocaching.apps.cache.navi;
+import java.util.UUID;
+
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
@@ -26,7 +28,7 @@ class StaticMapApp extends AbstractNavigationApp implements
@Override
public boolean invoke(cgGeo geo, Activity activity, Resources res,
cgCache cache,
- Long searchId, cgWaypoint waypoint, Double latitude, Double longitude) {
+ final UUID searchId, cgWaypoint waypoint, Double latitude, Double longitude) {
if (cache == null || cache.reason == 0) {
ActivityMixin.showToast(activity, res.getString(R.string.err_detail_no_map_static));
diff --git a/src/cgeo/geocaching/apps/cache/navi/StreetviewApp.java b/src/cgeo/geocaching/apps/cache/navi/StreetviewApp.java
index 24d6606..250bc65 100644
--- a/src/cgeo/geocaching/apps/cache/navi/StreetviewApp.java
+++ b/src/cgeo/geocaching/apps/cache/navi/StreetviewApp.java
@@ -1,5 +1,7 @@
package cgeo.geocaching.apps.cache.navi;
+import java.util.UUID;
+
import android.app.Activity;
import android.content.ActivityNotFoundException;
import android.content.Context;
@@ -25,7 +27,7 @@ class StreetviewApp extends AbstractNavigationApp implements NavigationApp {
public boolean invoke(cgGeo geo, Activity activity, Resources res,
cgCache cache,
- Long searchId, cgWaypoint waypoint, Double latitude, Double longitude) {
+ final UUID searchId, cgWaypoint waypoint, Double latitude, Double longitude) {
if (cache == null && waypoint == null && latitude == null && longitude == null) {
return false;
}
diff --git a/src/cgeo/geocaching/apps/cachelist/CacheListApp.java b/src/cgeo/geocaching/apps/cachelist/CacheListApp.java
index b58358c..74fba64 100644
--- a/src/cgeo/geocaching/apps/cachelist/CacheListApp.java
+++ b/src/cgeo/geocaching/apps/cachelist/CacheListApp.java
@@ -1,6 +1,7 @@
package cgeo.geocaching.apps.cachelist;
import java.util.List;
+import java.util.UUID;
import android.app.Activity;
import android.content.res.Resources;
@@ -12,6 +13,6 @@ interface CacheListApp extends App {
boolean invoke(final cgGeo geo, final List<cgCache> caches,
final Activity activity, final Resources res,
- final Long searchId);
+ final UUID searchId);
}
diff --git a/src/cgeo/geocaching/apps/cachelist/CacheListAppFactory.java b/src/cgeo/geocaching/apps/cachelist/CacheListAppFactory.java
index e26e049..cb69e17 100644
--- a/src/cgeo/geocaching/apps/cachelist/CacheListAppFactory.java
+++ b/src/cgeo/geocaching/apps/cachelist/CacheListAppFactory.java
@@ -2,6 +2,7 @@ package cgeo.geocaching.apps.cachelist;
import java.util.ArrayList;
import java.util.List;
+import java.util.UUID;
import org.apache.commons.lang3.ArrayUtils;
@@ -62,7 +63,7 @@ public final class CacheListAppFactory extends AbstractAppFactory {
public static boolean onMenuItemSelected(final MenuItem item,
final cgGeo geo, final List<cgCache> caches, final Activity activity, final Resources res,
- final Long searchId) {
+ final UUID searchId) {
CacheListApp app = (CacheListApp) getAppFromMenuItem(
item, apps);
if (app != null) {
diff --git a/src/cgeo/geocaching/apps/cachelist/InternalCacheListMap.java b/src/cgeo/geocaching/apps/cachelist/InternalCacheListMap.java
index 8576aab..2fd418e 100644
--- a/src/cgeo/geocaching/apps/cachelist/InternalCacheListMap.java
+++ b/src/cgeo/geocaching/apps/cachelist/InternalCacheListMap.java
@@ -1,6 +1,7 @@
package cgeo.geocaching.apps.cachelist;
import java.util.List;
+import java.util.UUID;
import android.app.Activity;
import android.content.Context;
@@ -23,11 +24,11 @@ class InternalCacheListMap extends AbstractApp implements CacheListApp {
}
@Override
- public boolean invoke(cgGeo geo, List<cgCache> caches, Activity activity, Resources res, Long searchId) {
+ public boolean invoke(cgGeo geo, List<cgCache> caches, Activity activity, Resources res, final UUID searchId) {
Intent mapIntent = new Intent(activity, getSettings(activity).getMapFactory()
.getMapClass());
mapIntent.putExtra("detail", false); // this is the main difference to the activity for a single point
- mapIntent.putExtra("searchid", searchId);
+ mapIntent.putExtra("searchid", searchId.toString());
activity.startActivity(mapIntent);
return true;
diff --git a/src/cgeo/geocaching/apps/cachelist/LocusCacheListApp.java b/src/cgeo/geocaching/apps/cachelist/LocusCacheListApp.java
index ca65b55..d72c398 100644
--- a/src/cgeo/geocaching/apps/cachelist/LocusCacheListApp.java
+++ b/src/cgeo/geocaching/apps/cachelist/LocusCacheListApp.java
@@ -4,6 +4,7 @@ import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.util.ArrayList;
import java.util.List;
+import java.util.UUID;
import org.apache.commons.lang3.StringUtils;
@@ -25,7 +26,7 @@ class LocusCacheListApp extends AbstractLocusApp implements CacheListApp {
}
@Override
- public boolean invoke(cgGeo geo, List<cgCache> cacheList, Activity activity, Resources res, final Long searchId) {
+ public boolean invoke(cgGeo geo, List<cgCache> cacheList, Activity activity, Resources res, final UUID searchId) {
if (cacheList == null || cacheList.isEmpty()) {
return false;
}
diff --git a/src/cgeo/geocaching/cgBase.java b/src/cgeo/geocaching/cgBase.java
index b7bc18e..1287f79 100644
--- a/src/cgeo/geocaching/cgBase.java
+++ b/src/cgeo/geocaching/cgBase.java
@@ -32,6 +32,7 @@ import java.util.Locale;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
+import java.util.UUID;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.zip.GZIPInputStream;
@@ -2737,7 +2738,7 @@ public class cgBase {
}
}
- public Long searchByNextPage(cgSearchThread thread, Long searchId, int reason, boolean showCaptcha) {
+ public UUID searchByNextPage(cgSearchThread thread, final UUID searchId, int reason, boolean showCaptcha) {
final String[] viewstates = app.getViewstates(searchId);
cgCacheWrap caches = new cgCacheWrap();
String url = app.getUrl(searchId);
@@ -2822,7 +2823,7 @@ public class cgBase {
return searchId;
}
- public Long searchByGeocode(Map<String, String> parameters, int reason, boolean forceReload) {
+ public UUID searchByGeocode(Map<String, String> parameters, int reason, boolean forceReload) {
final cgSearch search = new cgSearch();
String geocode = parameters.get("geocode");
String guid = parameters.get("guid");
@@ -2918,7 +2919,7 @@ public class cgBase {
return search.getCurrentId();
}
- public Long searchByOffline(Map<String, Object> parameters) {
+ public UUID searchByOffline(Map<String, Object> parameters) {
if (app == null) {
Log.e(cgSettings.tag, "cgeoBase.searchByOffline: No application found");
return null;
@@ -2948,7 +2949,7 @@ public class cgBase {
return search.getCurrentId();
}
- public Long searchByHistory(Map<String, Object> parameters) {
+ public UUID searchByHistory(Map<String, Object> parameters) {
if (app == null) {
Log.e(cgSettings.tag, "cgeoBase.searchByHistory: No application found");
return null;
@@ -2966,7 +2967,7 @@ public class cgBase {
return search.getCurrentId();
}
- public Long searchByCoords(cgSearchThread thread, Map<String, String> parameters, int reason, boolean showCaptcha) {
+ public UUID searchByCoords(cgSearchThread thread, Map<String, String> parameters, int reason, boolean showCaptcha) {
final cgSearch search = new cgSearch();
final String latitude = parameters.get("latitude");
final String longitude = parameters.get("longitude");
@@ -3024,7 +3025,7 @@ public class cgBase {
return search.getCurrentId();
}
- public Long searchByKeyword(cgSearchThread thread, Map<String, String> parameters, int reason, boolean showCaptcha) {
+ public UUID searchByKeyword(cgSearchThread thread, Map<String, String> parameters, int reason, boolean showCaptcha) {
final cgSearch search = new cgSearch();
final String keyword = parameters.get("keyword");
cgCacheWrap caches = new cgCacheWrap();
@@ -3075,7 +3076,7 @@ public class cgBase {
return search.getCurrentId();
}
- public Long searchByUsername(cgSearchThread thread, Map<String, String> parameters, int reason, boolean showCaptcha) {
+ public UUID searchByUsername(cgSearchThread thread, Map<String, String> parameters, int reason, boolean showCaptcha) {
final cgSearch search = new cgSearch();
final String userName = parameters.get("username");
cgCacheWrap caches = new cgCacheWrap();
@@ -3132,7 +3133,7 @@ public class cgBase {
return search.getCurrentId();
}
- public Long searchByOwner(cgSearchThread thread, Map<String, String> parameters, int reason, boolean showCaptcha) {
+ public UUID searchByOwner(cgSearchThread thread, Map<String, String> parameters, int reason, boolean showCaptcha) {
final cgSearch search = new cgSearch();
final String userName = parameters.get("username");
cgCacheWrap caches = new cgCacheWrap();
@@ -3183,7 +3184,7 @@ public class cgBase {
return search.getCurrentId();
}
- public Long searchByViewport(Map<String, String> parameters, int reason) {
+ public UUID searchByViewport(Map<String, String> parameters, int reason) {
final cgSearch search = new cgSearch();
final String latMin = parameters.get("latitude-min");
final String latMax = parameters.get("latitude-max");
@@ -4577,13 +4578,13 @@ public class cgBase {
if (cache.reason > 0 || StringUtils.isBlank(cache.description)) {
final Map<String, String> params = new HashMap<String, String>();
params.put("geocode", cache.geocode);
- final Long searchId = searchByGeocode(params, listId, false);
+ final UUID searchId = searchByGeocode(params, listId, false);
cache = app.getCache(searchId);
}
} else if (StringUtils.isNotBlank(geocode)) {
final Map<String, String> params = new HashMap<String, String>();
params.put("geocode", geocode);
- final Long searchId = searchByGeocode(params, listId, false);
+ final UUID searchId = searchByGeocode(params, listId, false);
cache = app.getCache(searchId);
}
diff --git a/src/cgeo/geocaching/cgSearch.java b/src/cgeo/geocaching/cgSearch.java
index 7b75760..76599b2 100644
--- a/src/cgeo/geocaching/cgSearch.java
+++ b/src/cgeo/geocaching/cgSearch.java
@@ -2,9 +2,10 @@ package cgeo.geocaching;
import java.util.ArrayList;
import java.util.List;
+import java.util.UUID;
public class cgSearch {
- private long id;
+ private UUID id;
private List<String> geocodes = new ArrayList<String>();
public String error = null;
@@ -13,10 +14,10 @@ public class cgSearch {
public int totalCnt = 0;
public cgSearch() {
- id = System.currentTimeMillis(); // possible collisions here - not guaranteed to be unique
+ id = UUID.randomUUID();
}
- public long getCurrentId() {
+ public UUID getCurrentId() {
return id;
}
diff --git a/src/cgeo/geocaching/cgeoapplication.java b/src/cgeo/geocaching/cgeoapplication.java
index 1eb5aa5..f580fa9 100644
--- a/src/cgeo/geocaching/cgeoapplication.java
+++ b/src/cgeo/geocaching/cgeoapplication.java
@@ -6,6 +6,7 @@ import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.UUID;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
@@ -25,7 +26,7 @@ public class cgeoapplication extends Application {
private boolean geoInUse = false;
private cgDirection dir = null;
private boolean dirInUse = false;
- final private Map<Long, cgSearch> searches = new HashMap<Long, cgSearch>(); // information about searches
+ 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 warnedLanguage = false; // user was warned about different language settings on geocaching.com
@@ -225,7 +226,7 @@ public class cgeoapplication extends Application {
return storage.getCacheidForGeocode(geocode);
}
- public String getError(Long searchId) {
+ public String getError(final UUID searchId) {
if (searchId == null || searches.containsKey(searchId) == false) {
return null;
}
@@ -233,7 +234,7 @@ public class cgeoapplication extends Application {
return searches.get(searchId).error;
}
- public boolean setError(Long searchId, String error) {
+ public boolean setError(final UUID searchId, String error) {
if (searchId == null || searches.containsKey(searchId) == false) {
return false;
}
@@ -243,7 +244,7 @@ public class cgeoapplication extends Application {
return true;
}
- public String getUrl(Long searchId) {
+ public String getUrl(final UUID searchId) {
if (searchId == null || searches.containsKey(searchId) == false) {
return null;
}
@@ -251,7 +252,7 @@ public class cgeoapplication extends Application {
return searches.get(searchId).url;
}
- public boolean setUrl(Long searchId, String url) {
+ public boolean setUrl(final UUID searchId, String url) {
if (searchId == null || searches.containsKey(searchId) == false) {
return false;
}
@@ -261,7 +262,7 @@ public class cgeoapplication extends Application {
return true;
}
- public String[] getViewstates(Long searchId) {
+ public String[] getViewstates(final UUID searchId) {
if (searchId == null || searches.containsKey(searchId) == false) {
return null;
}
@@ -269,7 +270,7 @@ public class cgeoapplication extends Application {
return searches.get(searchId).viewstates;
}
- public boolean setViewstates(Long searchId, String[] viewstates) {
+ public boolean setViewstates(final UUID searchId, String[] viewstates) {
if (ArrayUtils.isEmpty(viewstates)) {
return false;
}
@@ -282,7 +283,7 @@ public class cgeoapplication extends Application {
return true;
}
- public Integer getTotal(Long searchId) {
+ public Integer getTotal(final UUID searchId) {
if (searchId == null || searches.containsKey(searchId) == false) {
return null;
}
@@ -290,7 +291,7 @@ public class cgeoapplication extends Application {
return searches.get(searchId).totalCnt;
}
- public Integer getCount(Long searchId) {
+ public Integer getCount(final UUID searchId) {
if (searchId == null || searches.containsKey(searchId) == false) {
return 0;
}
@@ -298,7 +299,7 @@ public class cgeoapplication extends Application {
return searches.get(searchId).getCount();
}
- public Integer getNotOfflineCount(Long searchId) {
+ public Integer getNotOfflineCount(final UUID searchId) {
if (searchId == null || searches.containsKey(searchId) == false) {
return 0;
}
@@ -401,7 +402,7 @@ public class cgeoapplication extends Application {
return getBounds(geocodeList);
}
- public List<Object> getBounds(Long searchId) {
+ public List<Object> getBounds(final UUID searchId) {
if (searchId == null || searches.containsKey(searchId) == false) {
return null;
}
@@ -428,7 +429,7 @@ public class cgeoapplication extends Application {
return storage.getBounds(geocodes.toArray());
}
- public cgCache getCache(Long searchId) {
+ public cgCache getCache(final UUID searchId) {
if (searchId == null || searches.containsKey(searchId) == false) {
return null;
}
@@ -439,19 +440,19 @@ public class cgeoapplication extends Application {
return getCacheByGeocode(geocodeList.get(0), true, true, true, true, true, true);
}
- public List<cgCache> getCaches(Long searchId) {
+ public List<cgCache> getCaches(final UUID searchId) {
return getCaches(searchId, null, null, null, null, false, true, false, false, false, true);
}
- public List<cgCache> getCaches(Long searchId, boolean loadA, boolean loadW, boolean loadS, boolean loadL, boolean loadI, boolean loadO) {
+ public List<cgCache> getCaches(final UUID searchId, boolean loadA, boolean loadW, boolean loadS, boolean loadL, boolean loadI, boolean loadO) {
return getCaches(searchId, null, null, null, null, loadA, loadW, loadS, loadL, loadI, loadO);
}
- public List<cgCache> getCaches(Long searchId, Long centerLat, Long centerLon, Long spanLat, Long spanLon) {
+ 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(Long searchId, Long centerLat, Long centerLon, Long spanLat, Long spanLon, boolean loadA, boolean loadW, boolean loadS, boolean loadL, boolean loadI, boolean loadO) {
+ 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 (searchId == null || searches.containsKey(searchId) == false) {
List<cgCache> cachesOut = new ArrayList<cgCache>();
@@ -523,7 +524,7 @@ public class cgeoapplication extends Application {
return search;
}
- public Long getCachedInViewport(Long centerLat, Long centerLon, Long spanLat, Long spanLon, String cachetype) {
+ public UUID getCachedInViewport(Long centerLat, Long centerLon, Long spanLat, Long spanLon, String cachetype) {
if (storage == null) {
storage = new cgData(this);
}
@@ -540,7 +541,7 @@ public class cgeoapplication extends Application {
return search.getCurrentId();
}
- public Long getStoredInViewport(Long centerLat, Long centerLon, Long spanLat, Long spanLon, String cachetype) {
+ public UUID getStoredInViewport(Long centerLat, Long centerLon, Long spanLat, Long spanLon, String cachetype) {
if (storage == null) {
storage = new cgData(this);
}
@@ -557,7 +558,7 @@ public class cgeoapplication extends Application {
return search.getCurrentId();
}
- public Long getOfflineAll(String cachetype) {
+ public UUID getOfflineAll(String cachetype) {
if (storage == null) {
storage = new cgData(this);
}
@@ -659,7 +660,7 @@ public class cgeoapplication extends Application {
return storage.saveInventory("---", list);
}
- public void addGeocode(Long searchId, String geocode) {
+ public void addGeocode(final UUID searchId, String geocode) {
if (this.searches.containsKey(searchId) == false || StringUtils.isBlank(geocode)) {
return;
}
@@ -667,7 +668,7 @@ public class cgeoapplication extends Application {
this.searches.get(searchId).addGeocode(geocode);
}
- public Long addSearch(Long searchId, List<cgCache> cacheList, Boolean newItem, int reason) {
+ public UUID addSearch(final UUID searchId, List<cgCache> cacheList, Boolean newItem, int reason) {
if (this.searches.containsKey(searchId) == false) {
return null;
}
@@ -677,12 +678,12 @@ public class cgeoapplication extends Application {
return addSearch(search, cacheList, newItem, reason);
}
- public Long addSearch(final cgSearch search, final List<cgCache> cacheList, final boolean newItem, final int reason) {
+ public UUID addSearch(final cgSearch search, final List<cgCache> cacheList, final boolean newItem, final int reason) {
if (CollectionUtils.isEmpty(cacheList)) {
return null;
}
- final long searchId = search.getCurrentId();
+ final UUID searchId = search.getCurrentId();
searches.put(searchId, search);
if (storage == null) {
@@ -714,7 +715,7 @@ public class cgeoapplication extends Application {
return false;
}
- final long searchId = search.getCurrentId();
+ final UUID searchId = search.getCurrentId();
if (searches.containsKey(searchId) == false) {
searches.put(searchId, search);
diff --git a/src/cgeo/geocaching/cgeocaches.java b/src/cgeo/geocaching/cgeocaches.java
index 0a04b55..d8380bf 100644
--- a/src/cgeo/geocaching/cgeocaches.java
+++ b/src/cgeo/geocaching/cgeocaches.java
@@ -14,6 +14,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
+import java.util.UUID;
import org.apache.commons.lang3.StringUtils;
@@ -144,7 +145,7 @@ public class cgeocaches extends AbstractListActivity {
private String keyword = null;
private String address = null;
private String username = null;
- private Long searchId = null;
+ private UUID searchId = null;
private List<cgCache> cacheList = new ArrayList<cgCache>();
private cgCacheListAdapter adapter = null;
private LayoutInflater inflater = null;
@@ -174,7 +175,7 @@ public class cgeocaches extends AbstractListActivity {
@Override
public void handleMessage(Message msg) {
try {
- if (searchId != null && searchId > 0) {
+ if (searchId != null) {
setTitle(title + " [" + app.getCount(searchId) + "]");
cacheList.clear();
@@ -272,7 +273,7 @@ public class cgeocaches extends AbstractListActivity {
@Override
public void handleMessage(Message msg) {
try {
- if (searchId != null && searchId > 0) {
+ if (searchId != null) {
setTitle(title + " [" + app.getCount(searchId) + "]");
cacheList.clear();
@@ -1274,7 +1275,7 @@ public class cgeocaches extends AbstractListActivity {
// create a searchId for a single cache (as if in details view)
Map<String, String> params = new HashMap<String, String>();
params.put("geocode", cache.geocode);
- Long singleSearchId = base.searchByGeocode(params, 0, false);
+ final UUID singleSearchId = base.searchByGeocode(params, 0, false);
if (NavigationAppFactory.onMenuItemSelected(item, geo, this,
res, cache, singleSearchId, null, null)) {
@@ -2526,7 +2527,7 @@ public class cgeocaches extends AbstractListActivity {
}
public void goMap(View view) {
- if (searchId == null || searchId == 0 || CollectionUtils.isEmpty(cacheList)) {
+ if (searchId == null || CollectionUtils.isEmpty(cacheList)) {
showToast(res.getString(R.string.warn_no_cache_coord));
return;
@@ -2534,7 +2535,7 @@ public class cgeocaches extends AbstractListActivity {
Intent mapIntent = new Intent(this, settings.getMapFactory().getMapClass());
mapIntent.putExtra("detail", false);
- mapIntent.putExtra("searchid", searchId);
+ mapIntent.putExtra("searchid", searchId.toString());
startActivity(mapIntent);
}
diff --git a/src/cgeo/geocaching/cgeodetail.java b/src/cgeo/geocaching/cgeodetail.java
index e1d3ff2..182778d 100644
--- a/src/cgeo/geocaching/cgeodetail.java
+++ b/src/cgeo/geocaching/cgeodetail.java
@@ -10,6 +10,7 @@ import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Map.Entry;
+import java.util.UUID;
import org.apache.commons.lang3.StringUtils;
@@ -70,7 +71,7 @@ public class cgeodetail extends AbstractActivity {
super("c:geo-cache-details");
}
- public Long searchId = null;
+ public UUID searchId = null;
public cgCache cache = null;
public String geocode = null;
public String name = null;
@@ -163,7 +164,7 @@ public class cgeodetail extends AbstractActivity {
private Handler loadCacheHandler = new Handler() {
@Override
public void handleMessage(Message msg) {
- if (searchId == null || searchId <= 0) {
+ if (searchId == null) {
showToast(res.getString(R.string.err_dwld_details_failed));
finish();
@@ -573,7 +574,7 @@ public class cgeodetail extends AbstractActivity {
geo = app.startGeo(this, geoUpdate, base, settings, 0, 0);
}
- if (searchId != null && searchId > 0) {
+ if (searchId != null) {
cache = app.getCache(searchId);
if (cache != null && cache.geocode != null) {
geocode = cache.geocode;
diff --git a/src/cgeo/geocaching/cgeogpxes.java b/src/cgeo/geocaching/cgeogpxes.java
index 76c4c9e..92d0d48 100644
--- a/src/cgeo/geocaching/cgeogpxes.java
+++ b/src/cgeo/geocaching/cgeogpxes.java
@@ -2,6 +2,7 @@ package cgeo.geocaching;
import java.io.File;
import java.util.List;
+import java.util.UUID;
import android.app.Activity;
import android.app.ProgressDialog;
@@ -108,7 +109,7 @@ public class cgeogpxes extends FileList<cgGPXListAdapter> {
@Override
public void run() {
- final long searchId;
+ final UUID searchId;
String name = file.getName().toLowerCase();
if (name.endsWith("gpx")) {
searchId = GPXParser.parseGPX(app, file, listId, changeParseDialogHandler);
diff --git a/src/cgeo/geocaching/files/GPXParser.java b/src/cgeo/geocaching/files/GPXParser.java
index 707bd1a..0719621 100644
--- a/src/cgeo/geocaching/files/GPXParser.java
+++ b/src/cgeo/geocaching/files/GPXParser.java
@@ -9,6 +9,7 @@ import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
+import java.util.UUID;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -197,7 +198,7 @@ public abstract class GPXParser extends FileParser {
return formatSimple.parse(input);
}
- public long parse(final InputStream stream, Handler handlerIn) {
+ public UUID parse(final InputStream stream, Handler handlerIn) {
handler = handlerIn;
final RootElement root = new RootElement(namespace, "gpx");
@@ -657,16 +658,16 @@ public abstract class GPXParser extends FileParser {
} catch (SAXException e) {
Log.e(cgSettings.tag, "Cannot parse .gpx file as GPX " + version + ": could not parse XML - " + e.toString());
}
- return parsed ? search.getCurrentId() : 0L;
+ return parsed ? search.getCurrentId() : null;
}
- private long parse(final File file, final Handler handlerIn) {
+ private UUID parse(final File file, final Handler handlerIn) {
if (file == null) {
- return 0L;
+ return null;
}
FileInputStream fis = null;
- long result = 0L;
+ UUID result = null;
try {
fis = new FileInputStream(file);
result = parse(fis, handlerIn);
@@ -719,14 +720,14 @@ public abstract class GPXParser extends FileParser {
}
}
- public static Long parseGPX(cgeoapplication app, File file, int listId, Handler handler) {
+ public static UUID parseGPX(cgeoapplication app, File file, int listId, Handler handler) {
final cgSearch search = new cgSearch();
- long searchId = 0L;
+ UUID searchId = null;
try {
GPXParser parser = new GPX10Parser(app, listId, search);
searchId = parser.parse(file, handler);
- if (searchId == 0L) {
+ if (searchId == null) {
parser = new GPX11Parser(app, listId, search);
searchId = parser.parse(file, handler);
}
diff --git a/src/cgeo/geocaching/files/LocParser.java b/src/cgeo/geocaching/files/LocParser.java
index f1c83bd..9f7f525 100644
--- a/src/cgeo/geocaching/files/LocParser.java
+++ b/src/cgeo/geocaching/files/LocParser.java
@@ -4,6 +4,7 @@ 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;
@@ -144,10 +145,10 @@ public final class LocParser extends FileParser {
return coords;
}
- public static long parseLoc(cgeoapplication app, File file, int listId,
+ public static UUID parseLoc(cgeoapplication app, File file, int listId,
Handler handler) {
cgSearch search = new cgSearch();
- long searchId = 0L;
+ UUID searchId = null;
try {
Map<String, cgCoord> coords = parseCoordinates(readFile(file).toString());
diff --git a/src/cgeo/geocaching/mapcommon/cgeomap.java b/src/cgeo/geocaching/mapcommon/cgeomap.java
index d0a8b2e..c9fb60b 100644
--- a/src/cgeo/geocaching/mapcommon/cgeomap.java
+++ b/src/cgeo/geocaching/mapcommon/cgeomap.java
@@ -5,6 +5,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
+import java.util.UUID;
import android.app.Activity;
import android.app.ProgressDialog;
@@ -31,13 +32,13 @@ import cgeo.geocaching.cgCoord;
import cgeo.geocaching.cgDirection;
import cgeo.geocaching.cgGeo;
import cgeo.geocaching.cgSettings;
+import cgeo.geocaching.cgSettings.mapSourceEnum;
import cgeo.geocaching.cgUpdateDir;
import cgeo.geocaching.cgUpdateLoc;
import cgeo.geocaching.cgUser;
import cgeo.geocaching.cgWaypoint;
import cgeo.geocaching.cgeoapplication;
import cgeo.geocaching.activity.ActivityMixin;
-import cgeo.geocaching.cgSettings.mapSourceEnum;
import cgeo.geocaching.mapinterfaces.ActivityImpl;
import cgeo.geocaching.mapinterfaces.CacheOverlayItemImpl;
import cgeo.geocaching.mapinterfaces.GeoPointImpl;
@@ -76,14 +77,14 @@ public class cgeomap extends MapBase implements OnDragListener {
private cgUpdateDir dirUpdate = new UpdateDir();
// from intent
private boolean fromDetailIntent = false;
- private Long searchIdIntent = null;
+ private String searchIdIntent = null;
private String geocodeIntent = null;
private Double latitudeIntent = null;
private Double longitudeIntent = null;
private String waypointTypeIntent = null;
private int[] mapStateIntent = null;
// status data
- private Long searchId = null;
+ private UUID searchId = null;
private String token = null;
private boolean noMapTokenShowed = false;
// map status data
@@ -305,14 +306,14 @@ public class cgeomap extends MapBase implements OnDragListener {
Bundle extras = activity.getIntent().getExtras();
if (extras != null) {
fromDetailIntent = extras.getBoolean("detail");
- searchIdIntent = extras.getLong("searchid");
+ searchIdIntent = extras.getString("searchid");
geocodeIntent = extras.getString("geocode");
latitudeIntent = extras.getDouble("latitude");
longitudeIntent = extras.getDouble("longitude");
waypointTypeIntent = extras.getString("wpttype");
mapStateIntent = extras.getIntArray("mapstate");
- if (searchIdIntent == 0L) {
+ if ("".equals(searchIdIntent)) {
searchIdIntent = null;
}
if (latitudeIntent == 0.0) {
@@ -1064,7 +1065,7 @@ public class cgeomap extends MapBase implements OnDragListener {
// stage 1 - pull and render from the DB only
if (fromDetailIntent) {
- searchId = searchIdIntent;
+ searchId = UUID.fromString(searchIdIntent);
} else {
if (!live || settings.maplive == 0) {
searchId = app.getStoredInViewport(centerLat, centerLon, spanLat, spanLon, settings.cacheType);
@@ -1637,7 +1638,7 @@ public class cgeomap extends MapBase implements OnDragListener {
}
// move map to view results of searchIdIntent
- private void centerMap(String geocodeCenter, Long searchIdCenter, Double latitudeCenter, Double longitudeCenter, int[] mapState) {
+ private void centerMap(String geocodeCenter, String searchIdCenter, Double latitudeCenter, Double longitudeCenter, int[] mapState) {
if (!centered && mapState != null) {
try {