diff options
author | Bananeweizen <bananeweizen@gmx.de> | 2013-11-10 18:32:32 +0100 |
---|---|---|
committer | Bananeweizen <bananeweizen@gmx.de> | 2013-11-10 18:32:32 +0100 |
commit | 894a81d09e523c2f818b2e0cab89cd58b4f8febd (patch) | |
tree | bb6ed56fe7a38f9bdf22c158cce6d3feaa04aba8 /main/src/cgeo/geocaching/connector/ConnectorFactory.java | |
parent | 24e96ef66b990ec4851ce4cceb4d841090ae5ada (diff) | |
download | cgeo-894a81d09e523c2f818b2e0cab89cd58b4f8febd.zip cgeo-894a81d09e523c2f818b2e0cab89cd58b4f8febd.tar.gz cgeo-894a81d09e523c2f818b2e0cab89cd58b4f8febd.tar.bz2 |
fix #3425: Support Trackables With the QR Scanner Included in c:geo
Diffstat (limited to 'main/src/cgeo/geocaching/connector/ConnectorFactory.java')
-rw-r--r-- | main/src/cgeo/geocaching/connector/ConnectorFactory.java | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/main/src/cgeo/geocaching/connector/ConnectorFactory.java b/main/src/cgeo/geocaching/connector/ConnectorFactory.java index 3fdc11b..83f8142 100644 --- a/main/src/cgeo/geocaching/connector/ConnectorFactory.java +++ b/main/src/cgeo/geocaching/connector/ConnectorFactory.java @@ -21,6 +21,7 @@ import cgeo.geocaching.connector.trackable.UnknownTrackableConnector; import cgeo.geocaching.geopoint.Viewport; import org.apache.commons.lang3.StringUtils; +import org.eclipse.jdt.annotation.NonNull; import java.util.ArrayList; import java.util.List; @@ -50,7 +51,7 @@ public final class ConnectorFactory { UNKNOWN_CONNECTOR // the unknown connector MUST be the last one }; - public static final UnknownTrackableConnector UNKNOWN_TRACKABLE_CONNECTOR = new UnknownTrackableConnector(); + @NonNull public static final UnknownTrackableConnector UNKNOWN_TRACKABLE_CONNECTOR = new UnknownTrackableConnector(); private static final TrackableConnector[] TRACKABLE_CONNECTORS = new TrackableConnector[] { new GeokretyConnector(), // GK must be first, as it overlaps with the secret codes of travel bugs TravelBugConnector.getInstance(), @@ -133,6 +134,7 @@ public final class ConnectorFactory { return getTrackableConnector(trackable.getGeocode()); } + @NonNull public static TrackableConnector getTrackableConnector(String geocode) { for (final TrackableConnector connector : TRACKABLE_CONNECTORS) { if (connector.canHandleTrackable(geocode)) { @@ -187,4 +189,17 @@ public final class ConnectorFactory { return TRACKABLE_CONNECTORS; } + public static String getTrackableFromURL(final String url) { + if (url == null) { + return null; + } + for (final TrackableConnector connector : TRACKABLE_CONNECTORS) { + final String geocode = connector.getTrackableCodeFromUrl(url); + if (StringUtils.isNotBlank(geocode)) { + return geocode; + } + } + return null; + } + } |