From 203b55090e511cacb1bc464465e71366d8641359 Mon Sep 17 00:00:00 2001 From: campbeb Date: Wed, 29 May 2013 22:33:13 -1000 Subject: Fix #2799 - Retain trail on map when device is rotated --- main/src/cgeo/geocaching/maps/CGeoMap.java | 10 ++++++++++ main/src/cgeo/geocaching/maps/PositionOverlay.java | 11 +++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) (limited to 'main/src') diff --git a/main/src/cgeo/geocaching/maps/CGeoMap.java b/main/src/cgeo/geocaching/maps/CGeoMap.java index ea51375..97c4b7e 100644 --- a/main/src/cgeo/geocaching/maps/CGeoMap.java +++ b/main/src/cgeo/geocaching/maps/CGeoMap.java @@ -119,6 +119,7 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto private static final String BUNDLE_MAP_SOURCE = "mapSource"; private static final String BUNDLE_MAP_STATE = "mapState"; private static final String BUNDLE_LIVE_ENABLED = "liveEnabled"; + private static final String BUNDLE_TRAIL_HISTORY = "trailHistory"; private Resources res = null; private MapItemFactory mapItemFactory = null; @@ -343,6 +344,9 @@ 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 (overlayPosition != null) { + outState.putParcelableArrayList(BUNDLE_TRAIL_HISTORY, overlayPosition.getHistory()); + } } @Override @@ -380,11 +384,14 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto mapTitle = res.getString(R.string.map_map); } + ArrayList trailHistory = null; + // Get fresh map information from the bundle if any if (savedInstanceState != null) { currentSourceId = savedInstanceState.getInt(BUNDLE_MAP_SOURCE, Settings.getMapSource().getNumericalId()); mapStateIntent = savedInstanceState.getIntArray(BUNDLE_MAP_STATE); isLiveEnabled = savedInstanceState.getBoolean(BUNDLE_LIVE_ENABLED, false); + trailHistory = savedInstanceState.getParcelableArrayList(BUNDLE_TRAIL_HISTORY); } else { currentSourceId = Settings.getMapSource().getNumericalId(); } @@ -421,6 +428,9 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto if (overlayPosition == null) { overlayPosition = mapView.createAddPositionOverlay(activity); + if (trailHistory != null) { + overlayPosition.setHistory(trailHistory); + } } if (overlayScale == null) { diff --git a/main/src/cgeo/geocaching/maps/PositionOverlay.java b/main/src/cgeo/geocaching/maps/PositionOverlay.java index fec67ef..08acd2f 100644 --- a/main/src/cgeo/geocaching/maps/PositionOverlay.java +++ b/main/src/cgeo/geocaching/maps/PositionOverlay.java @@ -22,7 +22,6 @@ import android.graphics.Point; import android.location.Location; import java.util.ArrayList; -import java.util.List; public class PositionOverlay implements GeneralOverlay { private Location coordinates = null; @@ -39,7 +38,7 @@ public class PositionOverlay implements GeneralOverlay { private PaintFlagsDrawFilter setfil = null; private PaintFlagsDrawFilter remfil = null; private Location historyRecent = null; - private List history = new ArrayList(); + private ArrayList history = new ArrayList(); private Point historyPointN = new Point(); private Point historyPointP = new Point(); private Activity activity; @@ -229,4 +228,12 @@ public class PositionOverlay implements GeneralOverlay { public OverlayImpl getOverlayImpl() { return this.ovlImpl; } + + public ArrayList getHistory() { + return history; + } + + public void setHistory(ArrayList inHistory) { + history = inHistory; + } } -- cgit v1.1