aboutsummaryrefslogtreecommitdiffstats
path: root/main/src/cgeo/geocaching/maps/CGeoMap.java
diff options
context:
space:
mode:
authorblafoo <github@blafoo.de>2012-02-29 22:36:18 +0100
committerblafoo <github@blafoo.de>2012-02-29 22:36:18 +0100
commit3fde9652fdc7c7285e4aa00a447df2ae4359b8d9 (patch)
tree4023b13efd8bb326ab2332daee9785e5e4ae36fb /main/src/cgeo/geocaching/maps/CGeoMap.java
parentd66464638a5be700b4e54d33cfed65f518031f6d (diff)
downloadcgeo-3fde9652fdc7c7285e4aa00a447df2ae4359b8d9.zip
cgeo-3fde9652fdc7c7285e4aa00a447df2ae4359b8d9.tar.gz
cgeo-3fde9652fdc7c7285e4aa00a447df2ae4359b8d9.tar.bz2
Displaying changed caches in the Live Map. Improves #1184
Diffstat (limited to 'main/src/cgeo/geocaching/maps/CGeoMap.java')
-rw-r--r--main/src/cgeo/geocaching/maps/CGeoMap.java25
1 files changed, 24 insertions, 1 deletions
diff --git a/main/src/cgeo/geocaching/maps/CGeoMap.java b/main/src/cgeo/geocaching/maps/CGeoMap.java
index 35a6f9b..fb70d13 100644
--- a/main/src/cgeo/geocaching/maps/CGeoMap.java
+++ b/main/src/cgeo/geocaching/maps/CGeoMap.java
@@ -173,6 +173,7 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto
private boolean liveChanged = false; // previous state for loadTimer
private boolean centered = false; // if map is already centered
private boolean alreadyCentered = false; // -""- for setting my location
+ private static Set<String> dirtyCaches = null;
// handlers
/** Updates the titles */
final private Handler displayHandler = new Handler() {
@@ -439,6 +440,18 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto
dirUpdate.updateDirection(dir);
}
+ if (!CollectionUtils.isEmpty(dirtyCaches)) {
+ for (String geocode : dirtyCaches) {
+ cgCache cache = app.loadCache(geocode, LoadFlags.LOAD_CACHE_OR_DB);
+ // remove to update the cache
+ caches.remove(cache);
+ caches.add(cache);
+ }
+ dirtyCaches.clear();
+ // force an update of the display. Includes a call to DownloadThread :-(
+ liveChanged = true;
+ }
+
startTimer();
}
@@ -1299,7 +1312,10 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto
}
if (search != null) {
- caches.addAll(search.getCachesFromSearchResult(LoadFlags.LOAD_CACHE_OR_DB));
+ Set<cgCache> result = search.getCachesFromSearchResult(LoadFlags.LOAD_CACHE_OR_DB);
+ // to update the caches they have to be removed first
+ caches.removeAll(result);
+ caches.addAll(result);
}
if (stop) {
@@ -1830,6 +1846,13 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto
fromActivity.startActivity(mapIntent);
}
+ public static void markCacheAsDirty(final String geocode) {
+ if (dirtyCaches == null) {
+ dirtyCaches = new HashSet<String>();
+ }
+ dirtyCaches.add(geocode);
+ }
+
/**
* Returns a OverlayItem represented by an icon
*