aboutsummaryrefslogtreecommitdiffstats
path: root/main/src/cgeo/geocaching/connector/gc/GCConnector.java
diff options
context:
space:
mode:
authorBananeweizen <bananeweizen@gmx.de>2012-05-05 10:31:30 +0200
committerBananeweizen <bananeweizen@gmx.de>2012-05-05 10:31:30 +0200
commit057f24b4f57dadeeba92a04c83e3bcd790e983b1 (patch)
tree23464d3fd6a16c6ede3206bc39ed4b2e16d0419c /main/src/cgeo/geocaching/connector/gc/GCConnector.java
parent84c6bd6cc358b2cde2926a62990e4c151c47d6d1 (diff)
downloadcgeo-057f24b4f57dadeeba92a04c83e3bcd790e983b1.zip
cgeo-057f24b4f57dadeeba92a04c83e3bcd790e983b1.tar.gz
cgeo-057f24b4f57dadeeba92a04c83e3bcd790e983b1.tar.bz2
refactoring: more cleanup in connector interfaces
* switch from method overrides to interface detection for connector features * remove GCBase and put code into other classes * reduce GC specific code being used in general activities
Diffstat (limited to 'main/src/cgeo/geocaching/connector/gc/GCConnector.java')
-rw-r--r--main/src/cgeo/geocaching/connector/gc/GCConnector.java49
1 files changed, 20 insertions, 29 deletions
diff --git a/main/src/cgeo/geocaching/connector/gc/GCConnector.java b/main/src/cgeo/geocaching/connector/gc/GCConnector.java
index b461cc2..fbda5cd 100644
--- a/main/src/cgeo/geocaching/connector/gc/GCConnector.java
+++ b/main/src/cgeo/geocaching/connector/gc/GCConnector.java
@@ -6,7 +6,10 @@ import cgeo.geocaching.Settings;
import cgeo.geocaching.cgCache;
import cgeo.geocaching.cgeoapplication;
import cgeo.geocaching.connector.AbstractConnector;
+import cgeo.geocaching.connector.capability.ISearchByCenter;
+import cgeo.geocaching.connector.capability.ISearchByGeocode;
import cgeo.geocaching.enumerations.StatusCode;
+import cgeo.geocaching.geopoint.Geopoint;
import cgeo.geocaching.geopoint.Viewport;
import cgeo.geocaching.network.Parameters;
import cgeo.geocaching.utils.CancellableHandler;
@@ -15,10 +18,9 @@ import cgeo.geocaching.utils.Log;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
-import java.util.Set;
import java.util.regex.Pattern;
-public class GCConnector extends AbstractConnector {
+public class GCConnector extends AbstractConnector implements ISearchByGeocode, ISearchByCenter {
private static GCConnector instance;
private static final Pattern gpxZipFilePattern = Pattern.compile("\\d{7,}(_.+)?\\.zip", Pattern.CASE_INSENSITIVE);
@@ -43,11 +45,6 @@ public class GCConnector extends AbstractConnector {
}
@Override
- public boolean supportsRefreshCache(cgCache cache) {
- return true;
- }
-
- @Override
public String getCacheUrl(cgCache cache) {
// it would also be possible to use "http://www.geocaching.com/seek/cache_details.aspx?wp=" + cache.getGeocode();
return "http://coord.info/" + cache.getGeocode();
@@ -79,18 +76,7 @@ public class GCConnector extends AbstractConnector {
}
@Override
- public boolean supportsCachesAround() {
- return true;
- }
-
- @Override
- public SearchResult searchByGeocode(final String geocode, final String guid, final cgeoapplication app, final CancellableHandler handler) {
-
- if (app == null) {
- Log.e("cgeoBase.searchByGeocode: No application found");
- return null;
- }
-
+ public SearchResult searchByGeocode(final String geocode, final String guid, final CancellableHandler handler) {
final Parameters params = new Parameters("decrypt", "y");
if (StringUtils.isNotBlank(geocode)) {
params.put("wp", geocode);
@@ -106,11 +92,11 @@ public class GCConnector extends AbstractConnector {
if (StringUtils.isEmpty(page)) {
final SearchResult search = new SearchResult();
- if (app.isThere(geocode, guid, true, false)) {
+ if (cgeoapplication.getInstance().isThere(geocode, guid, true, false)) {
if (StringUtils.isBlank(geocode) && StringUtils.isNotBlank(guid)) {
Log.i("Loading old cache from cache.");
- search.addGeocode(app.getGeocode(guid));
+ search.addGeocode(cgeoapplication.getInstance().getGeocode(guid));
} else {
search.addGeocode(geocode);
}
@@ -134,13 +120,8 @@ public class GCConnector extends AbstractConnector {
}
@Override
- public SearchResult searchByGeocodes(Set<String> geocodes) {
- return GCBase.searchByGeocodes(geocodes);
- }
-
- @Override
public SearchResult searchByViewport(Viewport viewport, String[] tokens) {
- return GCBase.searchByViewport(viewport, tokens);
+ return GCMap.searchByViewport(viewport, tokens);
}
@Override
@@ -153,8 +134,18 @@ public class GCConnector extends AbstractConnector {
return cacheHasReliableLatLon;
}
+ public static int addToWatchlist(cgCache cache) {
+ return GCParser.addToWatchlist(cache);
+ }
+
+ public static int removeFromWatchlist(cgCache cache) {
+ return GCParser.removeFromWatchlist(cache);
+ }
+
@Override
- public String[] getTokens() {
- return GCBase.getTokens();
+ public SearchResult searchByCenter(Geopoint center) {
+ // TODO make search by coordinate use this method. currently it is just a marker that this connector supports search by center
+ return null;
}
+
}