diff options
| author | Bananeweizen <bananeweizen@gmx.de> | 2013-02-03 08:19:44 +0100 |
|---|---|---|
| committer | Bananeweizen <bananeweizen@gmx.de> | 2013-02-03 08:19:44 +0100 |
| commit | b6b73582a6d3f52017de98f0618f82724bdac15d (patch) | |
| tree | 42c167f52a4c71e5a8c9086552fa943cbc2ac539 /main/src/cgeo/geocaching/connector | |
| parent | 4a5fb3956448012c2e82a22e70c5a51974f781a8 (diff) | |
| download | cgeo-b6b73582a6d3f52017de98f0618f82724bdac15d.zip cgeo-b6b73582a6d3f52017de98f0618f82724bdac15d.tar.gz cgeo-b6b73582a6d3f52017de98f0618f82724bdac15d.tar.bz2 | |
respect exclude options when searching OC caches
Diffstat (limited to 'main/src/cgeo/geocaching/connector')
| -rw-r--r-- | main/src/cgeo/geocaching/connector/oc/OC11XMLParser.java | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/main/src/cgeo/geocaching/connector/oc/OC11XMLParser.java b/main/src/cgeo/geocaching/connector/oc/OC11XMLParser.java index 6e4c0f9..5776c12 100644 --- a/main/src/cgeo/geocaching/connector/oc/OC11XMLParser.java +++ b/main/src/cgeo/geocaching/connector/oc/OC11XMLParser.java @@ -244,16 +244,26 @@ public class OC11XMLParser { public void end() { cgCache cache = cacheHolder.cache; Geopoint coords = new Geopoint(cacheHolder.latitude, cacheHolder.longitude); - if (StringUtils.isNotBlank(cache.getGeocode()) - && !coords.equals(Geopoint.ZERO) - && !cache.isArchived() - && Settings.getCacheType().contains(cache) - && caches.size() < CACHE_PARSE_LIMIT) { - cache.setCoords(coords); + cache.setCoords(coords); + if (caches.size() < CACHE_PARSE_LIMIT && isValid(cache) && !isExcluded(cache)) { cache.setDetailedUpdatedNow(); caches.put(cache.getCacheId(), cache); } } + + private boolean isExcluded(cgCache cache) { + if (cache.isArchived() && Settings.isExcludeDisabledCaches()) { + return true; + } + if (cache.isFound() && Settings.isExcludeMyCaches()) { + return true; + } + return !Settings.getCacheType().contains(cache); + } + + private boolean isValid(cgCache cache) { + return StringUtils.isNotBlank(cache.getGeocode()) && !cache.getCoords().equals(Geopoint.ZERO); + } }); // cache.id @@ -662,6 +672,9 @@ public class OC11XMLParser { } } + /** + * Converts local links to absolute links targeting the OC website. + */ private static String linkify(String input) { String result = input; Matcher matcher = LOCAL_URL.matcher(result); @@ -685,7 +698,7 @@ public class OC11XMLParser { if (StringUtils.startsWith(input, PARAGRAPH_BEGIN) && StringUtils.endsWith(input, PARAGRAPH_END)) { String inner = input.substring(PARAGRAPH_BEGIN.length(), input.length() - PARAGRAPH_END.length()); if (!inner.contains(PARAGRAPH_BEGIN)) { - return inner; + return inner.trim(); } } return input; |
