aboutsummaryrefslogtreecommitdiffstats
path: root/main/src
diff options
context:
space:
mode:
Diffstat (limited to 'main/src')
-rw-r--r--main/src/cgeo/geocaching/connector/oc/OC11XMLParser.java21
-rw-r--r--main/src/cgeo/geocaching/connector/oc/OCXMLClient.java2
2 files changed, 19 insertions, 4 deletions
diff --git a/main/src/cgeo/geocaching/connector/oc/OC11XMLParser.java b/main/src/cgeo/geocaching/connector/oc/OC11XMLParser.java
index 3c2a826..6231c68 100644
--- a/main/src/cgeo/geocaching/connector/oc/OC11XMLParser.java
+++ b/main/src/cgeo/geocaching/connector/oc/OC11XMLParser.java
@@ -217,6 +217,16 @@ public class OC11XMLParser {
protected static int attributeId;
public static Collection<Geocache> parseCaches(final InputStream stream) throws IOException {
+ // parse and return caches without filtering
+ return parseCaches(stream, true);
+ }
+
+ public static Collection<Geocache> parseCachesFiltered(final InputStream stream) throws IOException {
+ // parse caches and filter result
+ return parseCaches(stream, false);
+ }
+
+ private static Collection<Geocache> parseCaches(final InputStream stream, boolean ignoreFiltersIn) throws IOException {
final Map<String, Geocache> caches = new HashMap<String, Geocache>();
final Map<String, LogEntry> logs = new HashMap<String, LogEntry>();
@@ -228,6 +238,8 @@ public class OC11XMLParser {
final RootElement root = new RootElement("oc11xml");
final Element cacheNode = root.getChild("cache");
+ final boolean ignoreFilters = ignoreFiltersIn;
+
// cache
cacheNode.setStartElementListener(new StartElementListener() {
@@ -245,17 +257,20 @@ public class OC11XMLParser {
Geocache cache = cacheHolder.cache;
Geopoint coords = new Geopoint(cacheHolder.latitude, cacheHolder.longitude);
cache.setCoords(coords);
- if (caches.size() < CACHE_PARSE_LIMIT && isValid(cache) && !isExcluded(cache)) {
+ if (caches.size() < CACHE_PARSE_LIMIT && isValid(cache) && (ignoreFilters || !isExcluded(cache))) {
cache.setDetailedUpdatedNow();
caches.put(cache.getCacheId(), cache);
}
}
private boolean isExcluded(Geocache cache) {
- if (cache.isArchived() && Settings.isExcludeDisabledCaches()) {
+ if (cache.isArchived()) {
+ return true;
+ }
+ if (cache.isDisabled() && Settings.isExcludeDisabledCaches()) {
return true;
}
- if (cache.isFound() && Settings.isExcludeMyCaches()) {
+ if ((cache.isFound() || cache.isOwner()) && Settings.isExcludeMyCaches()) {
return true;
}
return !Settings.getCacheType().contains(cache);
diff --git a/main/src/cgeo/geocaching/connector/oc/OCXMLClient.java b/main/src/cgeo/geocaching/connector/oc/OCXMLClient.java
index dee7bb9..6767b48 100644
--- a/main/src/cgeo/geocaching/connector/oc/OCXMLClient.java
+++ b/main/src/cgeo/geocaching/connector/oc/OCXMLClient.java
@@ -64,7 +64,7 @@ public class OCXMLClient {
return Collections.emptyList();
}
- return OC11XMLParser.parseCaches(new GZIPInputStream(data));
+ return OC11XMLParser.parseCachesFiltered(new GZIPInputStream(data));
} catch (IOException e) {
Log.e("Error parsing nearby search result", e);
return Collections.emptyList();