From e4e95a7a4660b4534427c78b1d00dd80b899a558 Mon Sep 17 00:00:00 2001 From: Bananeweizen Date: Mon, 9 Apr 2012 11:22:48 +0200 Subject: #1384: FC when apply a filter --- main/src/cgeo/geocaching/cgData.java | 10 ++-------- 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 geocodes = new HashSet(); - geocodes.add(geocode); - - Set caches = loadCaches(geocodes, loadFlags); - if (caches != null && caches.size() >= 1) { - return (cgCache) caches.toArray()[0]; - } - return null; + final Set 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); } -- cgit v1.1