diff options
Diffstat (limited to 'main/src/cgeo/geocaching/cgeoapplication.java')
-rw-r--r-- | main/src/cgeo/geocaching/cgeoapplication.java | 43 |
1 files changed, 10 insertions, 33 deletions
diff --git a/main/src/cgeo/geocaching/cgeoapplication.java b/main/src/cgeo/geocaching/cgeoapplication.java index 827e29f..c876d13 100644 --- a/main/src/cgeo/geocaching/cgeoapplication.java +++ b/main/src/cgeo/geocaching/cgeoapplication.java @@ -260,19 +260,9 @@ public class cgeoapplication extends Application { } public cgCache getCacheByGeocode(final String geocode, final EnumSet<LoadFlag> loadFlags) { - cgCache cache = CacheCache.getInstance().getCacheFromCache(geocode); - if (cache != null) { - return cache; - } - - cache = storage.loadCache(geocode, loadFlags); - if (cache != null && cache.isDetailed() && loadFlags == LoadFlags.LOADALL) { - // "Store" cache for the next access in the cache - CacheCache.getInstance().putCacheInCache(cache); - } + return storage.loadCache(geocode, loadFlags); - return cache; } public cgTrackable getTrackableByGeocode(String geocode) { @@ -294,6 +284,10 @@ public class cgeoapplication extends Application { CacheCache.getInstance().putCacheInCache(cache); } + public static cgCache getCacheFromCache(final String geocode) { + return CacheCache.getInstance().getCacheFromCache(geocode); + } + public String[] geocodesInCache() { return storage.allDetailedThere(); } @@ -342,36 +336,19 @@ public class cgeoapplication extends Application { * @return */ public Set<cgCache> getCaches(final SearchResult search, final boolean loadWaypoints) { - return getCaches(search, null, null, null, null, loadWaypoints ? EnumSet.of(LoadFlag.LOADWAYPOINTS, LoadFlag.LOADOFFLINELOG) : EnumSet.of(LoadFlag.LOADOFFLINELOG)); + return storage.loadCaches(search.getGeocodes(), loadWaypoints ? EnumSet.of(LoadFlag.LOADWAYPOINTS, LoadFlag.LOADOFFLINELOG) : EnumSet.of(LoadFlag.LOADOFFLINELOG)); } public Set<cgCache> getCaches(final SearchResult search, Long centerLat, Long centerLon, Long spanLat, Long spanLon) { - return getCaches(search, centerLat, centerLon, spanLat, spanLon, EnumSet.of(LoadFlag.LOADWAYPOINTS, LoadFlag.LOADOFFLINELOG)); - } - - public Set<cgCache> getCaches(final SearchResult search, final Long centerLat, final Long centerLon, final Long spanLat, final Long spanLon, final EnumSet<LoadFlag> loadFlags) { if (search == null) { - Set<cgCache> cachesOut = new HashSet<cgCache>(); - - final Set<cgCache> cachesPre = storage.loadCaches(null, centerLat, centerLon, spanLat, spanLon, loadFlags); - if (cachesPre != null) { - cachesOut.addAll(cachesPre); - } - - return cachesOut; + final Set<cgCache> cachesPre = storage.loadCaches(null, centerLat, centerLon, spanLat, spanLon, EnumSet.of(LoadFlag.LOADWAYPOINTS, LoadFlag.LOADOFFLINELOG)); + return cachesPre != null ? cachesPre : new HashSet<cgCache>(); } - Set<cgCache> cachesOut = new HashSet<cgCache>(); - - final Set<String> geocodeList = search.getGeocodes(); - // The list of geocodes is sufficient. more parameters generate an overly complex select. - final Set<cgCache> cachesPre = storage.loadCaches(geocodeList.toArray(), null, null, null, null, loadFlags); - if (cachesPre != null) { - cachesOut.addAll(cachesPre); - } + final Set<cgCache> cachesPre = storage.loadCaches(search.getGeocodes(), EnumSet.of(LoadFlag.LOADWAYPOINTS, LoadFlag.LOADOFFLINELOG)); + return cachesPre != null ? cachesPre : new HashSet<cgCache>(); - return cachesOut; } public SearchResult getBatchOfStoredCaches(final boolean detailedOnly, final Geopoint coords, final CacheType cacheType, final int list) { |