diff options
| author | Bananeweizen <bananeweizen@gmx.de> | 2013-12-20 08:41:24 +0100 |
|---|---|---|
| committer | Samuel Tardieu <sam@rfc1149.net> | 2013-12-27 19:59:31 +0100 |
| commit | 74b7b59e0eac6ec09c032baa6e9d9d27f0ec2f95 (patch) | |
| tree | 49f8d0ebaec9d37fd4086e40753fb0e3babda29d /main/src/cgeo/geocaching/maps/CGeoMap.java | |
| parent | 11ddb344d0b8d4c0a073dc01fc11c6729acb2e87 (diff) | |
| download | cgeo-74b7b59e0eac6ec09c032baa6e9d9d27f0ec2f95.zip cgeo-74b7b59e0eac6ec09c032baa6e9d9d27f0ec2f95.tar.gz cgeo-74b7b59e0eac6ec09c032baa6e9d9d27f0ec2f95.tar.bz2 | |
experimental single overlay for maps
Diffstat (limited to 'main/src/cgeo/geocaching/maps/CGeoMap.java')
| -rw-r--r-- | main/src/cgeo/geocaching/maps/CGeoMap.java | 29 |
1 files changed, 11 insertions, 18 deletions
diff --git a/main/src/cgeo/geocaching/maps/CGeoMap.java b/main/src/cgeo/geocaching/maps/CGeoMap.java index d8cad51..fedd765 100644 --- a/main/src/cgeo/geocaching/maps/CGeoMap.java +++ b/main/src/cgeo/geocaching/maps/CGeoMap.java @@ -154,7 +154,7 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto private volatile boolean downloaded = false; // overlays private CachesOverlay overlayCaches = null; - private PositionAndScaleOverlay overlayPositionAndScale = null; + // private PositionAndScaleOverlay overlayPositionAndScale = null; // data for overlays private static final int[][] INSET_RELIABLE = { { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 } }; // center, 33x40 / 45x51 / 60x68 private static final int[][] INSET_TYPE = { { 5, 8, 6, 10 }, { 4, 4, 5, 11 }, { 4, 4, 5, 11 } }; // center, 22x22 / 36x36 @@ -347,8 +347,8 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto outState.putInt(BUNDLE_MAP_SOURCE, currentSourceId); outState.putIntArray(BUNDLE_MAP_STATE, currentMapState()); outState.putBoolean(BUNDLE_LIVE_ENABLED, isLiveEnabled); - if (overlayPositionAndScale != null) { - outState.putParcelableArrayList(BUNDLE_TRAIL_HISTORY, overlayPositionAndScale.getHistory()); + if (overlayCaches != null) { + outState.putParcelableArrayList(BUNDLE_TRAIL_HISTORY, overlayCaches.getHistory()); } } @@ -426,13 +426,9 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto mapView.clearOverlays(); if (overlayCaches == null) { - overlayCaches = mapView.createAddMapOverlay(mapView.getContext(), getResources().getDrawable(R.drawable.marker)); - } - - if (overlayPositionAndScale == null) { - overlayPositionAndScale = mapView.createAddPositionAndScaleOverlay(activity); + overlayCaches = mapView.createAddMapOverlay(mapView.getContext(), getResources().getDrawable(R.drawable.marker), activity); if (trailHistory != null) { - overlayPositionAndScale.setHistory(trailHistory); + overlayCaches.setHistory(trailHistory); } } @@ -613,7 +609,7 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto switch (id) { case R.id.menu_trail_mode: Settings.setMapTrail(!Settings.isMapTrail()); - mapView.repaintRequired(overlayPositionAndScale); + mapView.repaintRequired(overlayCaches); ActivityMixin.invalidateOptionsMenu(activity); return true; case R.id.menu_map_live: @@ -920,9 +916,6 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto try { if (mapView != null) { - if (overlayPositionAndScale == null) { - overlayPositionAndScale = mapView.createAddPositionAndScaleOverlay(activity); - } boolean needsRepaintForDistance = needsRepaintForDistance(); boolean needsRepaintForHeading = needsRepaintForHeading(); @@ -934,9 +927,9 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto } if (needsRepaintForDistance || needsRepaintForHeading) { - overlayPositionAndScale.setCoordinates(currentLocation); - overlayPositionAndScale.setHeading(currentHeading); - mapView.repaintRequired(overlayPositionAndScale); + overlayCaches.setCoordinates(currentLocation); + overlayCaches.setHeading(currentHeading); + mapView.repaintRequired(overlayCaches); } } } catch (RuntimeException e) { @@ -946,7 +939,7 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto } boolean needsRepaintForHeading() { - return Math.abs(AngleUtils.difference(currentHeading, overlayPositionAndScale.getHeading())) > MIN_HEADING_DELTA; + return Math.abs(AngleUtils.difference(currentHeading, overlayCaches.getHeading())) > MIN_HEADING_DELTA; } boolean needsRepaintForDistance() { @@ -955,7 +948,7 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto return false; } - final Location lastLocation = overlayPositionAndScale.getCoordinates(); + final Location lastLocation = overlayCaches.getCoordinates(); float dist = Float.MAX_VALUE; if (lastLocation != null) { |
