diff options
| author | Bananeweizen <Bananeweizen@gmx.de> | 2013-03-12 10:27:39 -0700 |
|---|---|---|
| committer | Bananeweizen <Bananeweizen@gmx.de> | 2013-03-12 10:27:39 -0700 |
| commit | 2f6f6112dcf78afd114c9e6ada491120b6fb05e7 (patch) | |
| tree | 9d806af17ca3b5f7c416fbfa55bbe6b66ae921c8 | |
| parent | 1c8bc1fede16bbc6203061eb9a9ae334663c09d9 (diff) | |
| parent | 6de18e951489144131a9c09ca733c1f9ba4b973f (diff) | |
| download | cgeo-2f6f6112dcf78afd114c9e6ada491120b6fb05e7.zip cgeo-2f6f6112dcf78afd114c9e6ada491120b6fb05e7.tar.gz cgeo-2f6f6112dcf78afd114c9e6ada491120b6fb05e7.tar.bz2 | |
Merge pull request #2541 from koem/issue1640
Fixes #1640 - Found Caches shown on live map (low zoom problem)
| -rw-r--r-- | main/src/cgeo/geocaching/maps/CGeoMap.java | 23 |
1 files changed, 16 insertions, 7 deletions
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<Geocache> 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<Geocache> 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<Geocache> caches) { + boolean excludeMine = Settings.isExcludeMyCaches(); + boolean excludeDisabled = Settings.isExcludeDisabledCaches(); + + List<Geocache> removeList = new ArrayList<Geocache>(); + 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 || |
