diff options
| author | Bananeweizen <bananeweizen@gmx.de> | 2014-01-03 08:48:51 +0100 |
|---|---|---|
| committer | Bananeweizen <bananeweizen@gmx.de> | 2014-01-03 08:48:51 +0100 |
| commit | c0cf6d4d1d2a3d5fa8743c0cfce826370b08c32e (patch) | |
| tree | 4ab406cb0ada237f4add9fd56819b582e217e1ed /main/src/cgeo/geocaching/SearchResult.java | |
| parent | efe2fb79e2d3dd5b8077b26b5151a8f8d710e135 (diff) | |
| download | cgeo-c0cf6d4d1d2a3d5fa8743c0cfce826370b08c32e.zip cgeo-c0cf6d4d1d2a3d5fa8743c0cfce826370b08c32e.tar.gz cgeo-c0cf6d4d1d2a3d5fa8743c0cfce826370b08c32e.tar.bz2 | |
#3088: batch the database requests from the live map
Diffstat (limited to 'main/src/cgeo/geocaching/SearchResult.java')
| -rw-r--r-- | main/src/cgeo/geocaching/SearchResult.java | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/main/src/cgeo/geocaching/SearchResult.java b/main/src/cgeo/geocaching/SearchResult.java index 5d63a2d..131a01c 100644 --- a/main/src/cgeo/geocaching/SearchResult.java +++ b/main/src/cgeo/geocaching/SearchResult.java @@ -126,9 +126,7 @@ public class SearchResult implements Parcelable { */ public SearchResult(final Collection<Geocache> caches) { this(); - for (final Geocache cache : caches) { - addAndPutInCache(cache); - } + addAndPutInCache(caches); } @Override @@ -209,7 +207,7 @@ public class SearchResult implements Parcelable { SearchResult result = new SearchResult(this); result.geocodes.clear(); - final ArrayList<Geocache> cachesForVote = new ArrayList<Geocache>(); + final ArrayList<Geocache> includedCaches = new ArrayList<Geocache>(); final Set<Geocache> caches = DataStore.loadCaches(geocodes, LoadFlags.LOAD_CACHE_OR_DB); int excluded = 0; for (Geocache cache : caches) { @@ -220,13 +218,13 @@ public class SearchResult implements Parcelable { if (excludeCache) { excluded++; } else { - result.addAndPutInCache(cache); - cachesForVote.add(cache); + includedCaches.add(cache); } } + result.addAndPutInCache(includedCaches); // decrease maximum number of caches by filtered ones result.setTotalCountGC(result.getTotalCountGC() - excluded); - GCVote.loadRatings(cachesForVote); + GCVote.loadRatings(includedCaches); return result; } @@ -252,9 +250,11 @@ public class SearchResult implements Parcelable { } /** Add the cache geocode to the search and store the cache in the CacheCache */ - public boolean addAndPutInCache(final Geocache cache) { - addGeocode(cache.getGeocode()); - return DataStore.saveCache(cache, EnumSet.of(SaveFlag.SAVE_CACHE)); + public void addAndPutInCache(final Collection<Geocache> caches) { + for (Geocache geocache : caches) { + addGeocode(geocache.getGeocode()); + } + DataStore.saveCaches(caches, EnumSet.of(SaveFlag.SAVE_CACHE)); } public boolean isEmpty() { |
