diff options
| author | rsudev <rasch@munin-soft.de> | 2013-07-06 15:08:08 +0200 |
|---|---|---|
| committer | rsudev <rasch@munin-soft.de> | 2013-07-06 15:08:08 +0200 |
| commit | 7595b69b01a2e43befb2565a23a9b3f6c8736160 (patch) | |
| tree | d26e3fcdb1c218eaf232dfdc215f227680c38ae6 /main/src/cgeo/geocaching/maps/CGeoMap.java | |
| parent | 06e089bd300a3967f1c50d6509bdc8a0b792bdad (diff) | |
| download | cgeo-7595b69b01a2e43befb2565a23a9b3f6c8736160.zip cgeo-7595b69b01a2e43befb2565a23a9b3f6c8736160.tar.gz cgeo-7595b69b01a2e43befb2565a23a9b3f6c8736160.tar.bz2 | |
Fixes #2826, Found caches shown on live map
Implemented detection and filtering for vanishing caches
Added testcases for new functionality
Diffstat (limited to 'main/src/cgeo/geocaching/maps/CGeoMap.java')
| -rw-r--r-- | main/src/cgeo/geocaching/maps/CGeoMap.java | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/main/src/cgeo/geocaching/maps/CGeoMap.java b/main/src/cgeo/geocaching/maps/CGeoMap.java index c876192..a2b70c7 100644 --- a/main/src/cgeo/geocaching/maps/CGeoMap.java +++ b/main/src/cgeo/geocaching/maps/CGeoMap.java @@ -17,6 +17,7 @@ import cgeo.geocaching.connector.gc.Login; import cgeo.geocaching.enumerations.CacheType; import cgeo.geocaching.enumerations.LiveMapStrategy.Strategy; import cgeo.geocaching.enumerations.LoadFlags; +import cgeo.geocaching.enumerations.LoadFlags.RemoveFlag; import cgeo.geocaching.enumerations.StatusCode; import cgeo.geocaching.enumerations.WaypointType; import cgeo.geocaching.geopoint.Geopoint; @@ -70,6 +71,7 @@ import android.widget.ViewSwitcher.ViewFactory; import java.io.File; import java.util.ArrayList; import java.util.Collection; +import java.util.EnumSet; import java.util.HashSet; import java.util.List; import java.util.Set; @@ -1082,8 +1084,7 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto } // live mode search result if (isLiveEnabled) { - SearchResult liveResult = new SearchResult(cgData.loadCachedInViewport(viewport, Settings.getCacheType())); - searchResult.addGeocodes(liveResult.getGeocodes()); + searchResult.addSearchResult(cgData.loadCachedInViewport(viewport, Settings.getCacheType())); } downloaded = true; @@ -1179,7 +1180,12 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto Set<Geocache> result = searchResult.getCachesFromSearchResult(LoadFlags.LOAD_CACHE_OR_DB); CGeoMap.filter(result); // update the caches - // new collection type needs to remove first + // first remove filtered out + final Set<String> filteredCodes = searchResult.getFilteredGeocodes(); + Log.d("Filtering out " + filteredCodes.size() + " caches: " + filteredCodes.toString()); + caches.removeAll(cgData.loadCaches(filteredCodes, LoadFlags.LOAD_CACHE_ONLY)); + cgData.removeCaches(filteredCodes, EnumSet.of(RemoveFlag.REMOVE_CACHE)); + // new collection type needs to remove first to refresh caches.removeAll(result); caches.addAll(result); lastSearchResult = searchResult; |
