diff options
author | Samuel Tardieu <sam@rfc1149.net> | 2012-06-17 12:28:44 +0200 |
---|---|---|
committer | Samuel Tardieu <sam@rfc1149.net> | 2012-06-17 12:29:48 +0200 |
commit | 4cfa9802ed20d1ba979ca95c75b39e5d2facd890 (patch) | |
tree | 4c2e93260e034fdbdca6f849b55854d0fcc78a0f /main/src | |
parent | 0b4e82013287e8001f1a523fd0cf03d1f704f9a5 (diff) | |
download | cgeo-4cfa9802ed20d1ba979ca95c75b39e5d2facd890.zip cgeo-4cfa9802ed20d1ba979ca95c75b39e5d2facd890.tar.gz cgeo-4cfa9802ed20d1ba979ca95c75b39e5d2facd890.tar.bz2 |
Clear overlays cache to help with bitmap memory pressure
The overlays cache can be rebuilt once per activity view. We can free
the bitmap memory when we are not displaying overlays.
Diffstat (limited to 'main/src')
-rw-r--r-- | main/src/cgeo/geocaching/maps/CGeoMap.java | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/main/src/cgeo/geocaching/maps/CGeoMap.java b/main/src/cgeo/geocaching/maps/CGeoMap.java index 79ea44a..69c3530 100644 --- a/main/src/cgeo/geocaching/maps/CGeoMap.java +++ b/main/src/cgeo/geocaching/maps/CGeoMap.java @@ -174,7 +174,7 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto private static final int[][] INSET_USERMODIFIEDCOORDS = { { 21, 28, 0, 0 }, { 19, 25, 0, 0 } }; // bottom right, 12x12 / 26x26 private static final int[][] INSET_PERSONALNOTE = { { 0, 28, 21, 0 }, { 0, 25, 19, 0 } }; // bottom left, 12x12 / 26x26 - private static SparseArray<LayerDrawable> overlaysCache = new SparseArray<LayerDrawable>(); + private SparseArray<LayerDrawable> overlaysCache = new SparseArray<LayerDrawable>(); private int cachesCnt = 0; /** List of caches in the viewport */ private LeastRecentlyUsedSet<cgCache> caches = null; @@ -540,6 +540,8 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto mapView.destroyDrawingCache(); } + overlaysCache.clear(); + super.onPause(); } @@ -1664,7 +1666,7 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto .append(cache.getListId() > 0) .toHashCode(); - final LayerDrawable ldFromCache = CGeoMap.overlaysCache.get(hashcode); + final LayerDrawable ldFromCache = overlaysCache.get(hashcode); if (ldFromCache != null) { item.setMarker(ldFromCache); return item; @@ -1722,7 +1724,7 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto ld.setLayerInset(index++, inset[0], inset[1], inset[2], inset[3]); } - CGeoMap.overlaysCache.put(hashcode, ld); + overlaysCache.put(hashcode, ld); item.setMarker(ld); return item; |