From 6de18e951489144131a9c09ca733c1f9ba4b973f Mon Sep 17 00:00:00 2001 From: koem Date: Tue, 5 Mar 2013 15:29:12 +1300 Subject: issue 1640 - Found Caches shown on live map (low zoom problem) solved --- main/src/cgeo/geocaching/maps/CGeoMap.java | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) (limited to 'main/src/cgeo/geocaching') diff --git a/main/src/cgeo/geocaching/maps/CGeoMap.java b/main/src/cgeo/geocaching/maps/CGeoMap.java index 4b8d1a0..3b15965 100644 --- a/main/src/cgeo/geocaching/maps/CGeoMap.java +++ b/main/src/cgeo/geocaching/maps/CGeoMap.java @@ -69,6 +69,7 @@ import android.widget.ViewSwitcher.ViewFactory; import java.io.File; import java.util.ArrayList; +import java.util.Collection; import java.util.HashSet; import java.util.List; import java.util.Set; @@ -1109,13 +1110,7 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto final boolean excludeMine = Settings.isExcludeMyCaches(); final boolean excludeDisabled = Settings.isExcludeDisabledCaches(); if (mapMode == MapMode.LIVE) { - final List tempList = caches.getAsList(); - - for (Geocache cache : tempList) { - if ((cache.isFound() && excludeMine) || (cache.isOwner() && excludeMine) || (cache.isDisabled() && excludeDisabled)) { - caches.remove(cache); - } - } + CGeoMap.filter(caches); } countVisibleCaches(); if (cachesCnt < Settings.getWayPointsThreshold() || geocodeIntent != null) { @@ -1196,6 +1191,7 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto if (searchResult != null) { Set result = searchResult.getCachesFromSearchResult(LoadFlags.LOAD_CACHE_OR_DB); + CGeoMap.filter(result); // update the caches // new collection type needs to remove first caches.removeAll(result); @@ -1451,6 +1447,19 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto } } + private static void filter(Collection caches) { + boolean excludeMine = Settings.isExcludeMyCaches(); + boolean excludeDisabled = Settings.isExcludeDisabledCaches(); + + List removeList = new ArrayList(); + for (Geocache cache : caches) { + if ((cache.isFound() && excludeMine) || (cache.isOwner() && excludeMine) || (cache.isDisabled() && excludeDisabled)) { + removeList.add(cache); + } + } + caches.removeAll(removeList); + } + private static boolean mapMoved(final Viewport referenceViewport, final Viewport newViewport) { return Math.abs(newViewport.getLatitudeSpan() - referenceViewport.getLatitudeSpan()) > 50e-6 || Math.abs(newViewport.getLongitudeSpan() - referenceViewport.getLongitudeSpan()) > 50e-6 || -- cgit v1.1