diff options
| author | Bananeweizen <bananeweizen@gmx.de> | 2013-06-01 11:16:06 +0200 |
|---|---|---|
| committer | Bananeweizen <bananeweizen@gmx.de> | 2013-06-01 11:16:06 +0200 |
| commit | 1222116a3c6f4737859fe93d5bf81786ae4340e2 (patch) | |
| tree | cd5c862f2a7e9a4412ae0511fcf3f8acec2a328f /main/src/cgeo | |
| parent | 07865d8cc30ffee82987c9aba5c5dfad70e7f55d (diff) | |
| download | cgeo-1222116a3c6f4737859fe93d5bf81786ae4340e2.zip cgeo-1222116a3c6f4737859fe93d5bf81786ae4340e2.tar.gz cgeo-1222116a3c6f4737859fe93d5bf81786ae4340e2.tar.bz2 | |
refactoring: extract method to simplify control flow
Diffstat (limited to 'main/src/cgeo')
| -rw-r--r-- | main/src/cgeo/geocaching/maps/CGeoMap.java | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/main/src/cgeo/geocaching/maps/CGeoMap.java b/main/src/cgeo/geocaching/maps/CGeoMap.java index 0ddaa75..19e4697 100644 --- a/main/src/cgeo/geocaching/maps/CGeoMap.java +++ b/main/src/cgeo/geocaching/maps/CGeoMap.java @@ -1631,12 +1631,15 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto .append(cache.getListId() > 0) .toHashCode(); - final LayerDrawable ldFromCache = overlaysCache.get(hashcode); - if (ldFromCache != null) { - item.setMarker(ldFromCache); - return item; + LayerDrawable drawable = overlaysCache.get(hashcode); + if (drawable == null) { + drawable = createCacheItem(cache, hashcode); } + item.setMarker(drawable); + return item; + } + private LayerDrawable createCacheItem(final Geocache cache, final int hashcode) { // Set initial capacities to the maximum of layers and insets to avoid dynamic reallocation final ArrayList<Drawable> layers = new ArrayList<Drawable>(9); final ArrayList<int[]> insets = new ArrayList<int[]>(8); @@ -1690,9 +1693,7 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto } overlaysCache.put(hashcode, ld); - - item.setMarker(ld); - return item; + return ld; } private CachesOverlayItemImpl getWaypointItem(final Waypoint waypoint) { |
