diff options
| author | Bananeweizen <bananeweizen@gmx.de> | 2015-02-21 11:43:42 +0100 |
|---|---|---|
| committer | Bananeweizen <bananeweizen@gmx.de> | 2015-02-21 11:43:42 +0100 |
| commit | 0f28169faf68b19b1218bf3c6e32c52b42017909 (patch) | |
| tree | 42c4aa550766d7f3066a64fe505bbf5855146ff3 /main/src/cgeo/geocaching/utils/CheckerUtils.java | |
| parent | 5d001f813364ef96988ab432d59e2a3c82dd60d5 (diff) | |
| download | cgeo-0f28169faf68b19b1218bf3c6e32c52b42017909.zip cgeo-0f28169faf68b19b1218bf3c6e32c52b42017909.tar.gz cgeo-0f28169faf68b19b1218bf3c6e32c52b42017909.tar.bz2 | |
new: menu item to open geo checker
Diffstat (limited to 'main/src/cgeo/geocaching/utils/CheckerUtils.java')
| -rw-r--r-- | main/src/cgeo/geocaching/utils/CheckerUtils.java | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/main/src/cgeo/geocaching/utils/CheckerUtils.java b/main/src/cgeo/geocaching/utils/CheckerUtils.java new file mode 100644 index 0000000..956ebbf --- /dev/null +++ b/main/src/cgeo/geocaching/utils/CheckerUtils.java @@ -0,0 +1,34 @@ +package cgeo.geocaching.utils; + +import cgeo.geocaching.Geocache; + +import org.apache.commons.lang3.StringUtils; +import org.eclipse.jdt.annotation.NonNull; +import org.eclipse.jdt.annotation.Nullable; + +import android.util.Patterns; + +import java.util.regex.Matcher; + +public final class CheckerUtils { + private static final String[] CHECKERS = new String[] { "geocheck.org", "geochecker.com", "certitudes.org" }; + + private CheckerUtils() { + // utility class + } + + @Nullable + public static String getCheckerUrl(@NonNull final Geocache cache) { + final String description = cache.getDescription(); + final Matcher matcher = Patterns.WEB_URL.matcher(description); + while (matcher.find()) { + final String url = matcher.group(); + for (final String checker : CHECKERS) { + if (StringUtils.containsIgnoreCase(url, checker)) { + return url; + } + } + } + return null; + } +} |
