diff options
author | Bananeweizen <Bananeweizen@gmx.de> | 2012-04-09 11:22:48 +0200 |
---|---|---|
committer | Bananeweizen <Bananeweizen@gmx.de> | 2012-04-09 11:22:48 +0200 |
commit | e4e95a7a4660b4534427c78b1d00dd80b899a558 (patch) | |
tree | 2ad7a91a1ee62b3281bdd8f125842308c2ff30b7 | |
parent | 29d1fb0f121f6233a4d43d4c2cd8a12d5101f1f5 (diff) | |
download | cgeo-e4e95a7a4660b4534427c78b1d00dd80b899a558.zip cgeo-e4e95a7a4660b4534427c78b1d00dd80b899a558.tar.gz cgeo-e4e95a7a4660b4534427c78b1d00dd80b899a558.tar.bz2 |
#1384: FC when apply a filter
-rw-r--r-- | main/src/cgeo/geocaching/cgData.java | 10 | ||||
-rw-r--r-- | main/src/cgeo/geocaching/filter/AttributeFilter.java | 5 |
2 files changed, 6 insertions, 9 deletions
diff --git a/main/src/cgeo/geocaching/cgData.java b/main/src/cgeo/geocaching/cgData.java index 24f1e22..b711de6 100644 --- a/main/src/cgeo/geocaching/cgData.java +++ b/main/src/cgeo/geocaching/cgData.java @@ -1801,14 +1801,8 @@ public class cgData { throw new IllegalArgumentException("geocode must not be empty"); } - Set<String> geocodes = new HashSet<String>(); - geocodes.add(geocode); - - Set<cgCache> caches = loadCaches(geocodes, loadFlags); - if (caches != null && caches.size() >= 1) { - return (cgCache) caches.toArray()[0]; - } - return null; + final Set<cgCache> caches = loadCaches(Collections.singleton(geocode), loadFlags); + return caches.isEmpty() ? null : caches.iterator().next(); } /** diff --git a/main/src/cgeo/geocaching/filter/AttributeFilter.java b/main/src/cgeo/geocaching/filter/AttributeFilter.java index 0ef0787..7b8992b 100644 --- a/main/src/cgeo/geocaching/filter/AttributeFilter.java +++ b/main/src/cgeo/geocaching/filter/AttributeFilter.java @@ -34,7 +34,10 @@ public class AttributeFilter extends AbstractFilter { @Override public boolean accepts(final cgCache cache) { - final cgCache fullCache = cgeoapplication.getInstance().loadCache(cache.getGeocode(), EnumSet.of(LoadFlag.LOAD_ATTRIBUTES)); + cgCache fullCache = cgeoapplication.getInstance().loadCache(cache.getGeocode(), EnumSet.of(LoadFlag.LOAD_ATTRIBUTES)); + if (fullCache == null) { + fullCache = cache; + } return fullCache.getAttributes().contains(attribute); } |