aboutsummaryrefslogtreecommitdiffstats
path: root/main/src/cgeo/geocaching/connector
diff options
context:
space:
mode:
authorBananeweizen <bananeweizen@gmx.de>2015-02-18 23:11:35 +0100
committerBananeweizen <bananeweizen@gmx.de>2015-02-18 23:11:35 +0100
commit45fdd532dd57dc48cab99595db06f40b4ac74114 (patch)
tree9a38c1bbdbff684899be5655c17d4da71ade304d /main/src/cgeo/geocaching/connector
parente212c8a43ef6c0503837794b04f14362217a882f (diff)
downloadcgeo-45fdd532dd57dc48cab99595db06f40b4ac74114.zip
cgeo-45fdd532dd57dc48cab99595db06f40b4ac74114.tar.gz
cgeo-45fdd532dd57dc48cab99595db06f40b4ac74114.tar.bz2
decode CZ cache ids
Diffstat (limited to 'main/src/cgeo/geocaching/connector')
-rw-r--r--main/src/cgeo/geocaching/connector/ConnectorFactory.java3
-rw-r--r--main/src/cgeo/geocaching/connector/oc/OCCZConnector.java31
2 files changed, 33 insertions, 1 deletions
diff --git a/main/src/cgeo/geocaching/connector/ConnectorFactory.java b/main/src/cgeo/geocaching/connector/ConnectorFactory.java
index 71473b6..918911a 100644
--- a/main/src/cgeo/geocaching/connector/ConnectorFactory.java
+++ b/main/src/cgeo/geocaching/connector/ConnectorFactory.java
@@ -15,6 +15,7 @@ import cgeo.geocaching.connector.gc.GCConnector;
import cgeo.geocaching.connector.gc.MapTokens;
import cgeo.geocaching.connector.oc.OCApiConnector.ApiSupport;
import cgeo.geocaching.connector.oc.OCApiLiveConnector;
+import cgeo.geocaching.connector.oc.OCCZConnector;
import cgeo.geocaching.connector.oc.OCConnector;
import cgeo.geocaching.connector.ox.OXConnector;
import cgeo.geocaching.connector.trackable.GeokretyConnector;
@@ -44,7 +45,7 @@ public final class ConnectorFactory {
new OCApiLiveConnector("opencaching.de", "www.opencaching.de", "OC", "CC BY-NC-ND, alle Logeinträge © jeweiliger Autor",
R.string.oc_de_okapi_consumer_key, R.string.oc_de_okapi_consumer_secret,
R.string.pref_connectorOCActive, R.string.pref_ocde_tokenpublic, R.string.pref_ocde_tokensecret, ApiSupport.current),
- new OCConnector("OpenCaching.CZ", "www.opencaching.cz", "OZ"),
+ new OCCZConnector(),
new OCApiLiveConnector("opencaching.org.uk", "www.opencaching.org.uk", "OK", "CC BY-NC-SA 2.5",
R.string.oc_uk_okapi_consumer_key, R.string.oc_uk_okapi_consumer_secret,
R.string.pref_connectorOCUKActive, R.string.pref_ocuk_tokenpublic, R.string.pref_ocuk_tokensecret, ApiSupport.oldapi),
diff --git a/main/src/cgeo/geocaching/connector/oc/OCCZConnector.java b/main/src/cgeo/geocaching/connector/oc/OCCZConnector.java
new file mode 100644
index 0000000..0ffbbef
--- /dev/null
+++ b/main/src/cgeo/geocaching/connector/oc/OCCZConnector.java
@@ -0,0 +1,31 @@
+package cgeo.geocaching.connector.oc;
+
+import cgeo.geocaching.utils.Log;
+
+import org.apache.commons.lang3.StringUtils;
+import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.jdt.annotation.Nullable;
+
+public class OCCZConnector extends OCConnector {
+
+ private static final String GEOCODE_PREFIX = "OZ";
+
+ public OCCZConnector() {
+ super("OpenCaching.CZ", "www.opencaching.cz", GEOCODE_PREFIX);
+ }
+
+ @Override
+ @Nullable
+ public String getGeocodeFromUrl(@NonNull final String url) {
+ final String id = StringUtils.substringAfter(url, "cacheid=");
+ try {
+ final String geocode = GEOCODE_PREFIX + StringUtils.leftPad(Integer.toHexString(Integer.valueOf(id)), 4, '0');
+ if (canHandle(geocode)) {
+ return geocode;
+ }
+ } catch (final NumberFormatException e) {
+ Log.e("Unexpected URL for opencaching.cz " + url);
+ }
+ return super.getGeocodeFromUrl(url);
+ }
+}