From 59b8b2e26a7fff6072c4d5d96f51035dc900e0bc Mon Sep 17 00:00:00 2001 From: Bananeweizen Date: Sun, 19 Apr 2015 10:20:31 +0200 Subject: fix #4884: Heading line has wrong target when started from compass --- main/src/cgeo/geocaching/CompassActivity.java | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/main/src/cgeo/geocaching/CompassActivity.java b/main/src/cgeo/geocaching/CompassActivity.java index e4e1cca..3f6fe6a 100644 --- a/main/src/cgeo/geocaching/CompassActivity.java +++ b/main/src/cgeo/geocaching/CompassActivity.java @@ -56,9 +56,13 @@ public class CompassActivity extends AbstractActionBarActivity { @InjectView(R.id.cacheinfo) protected TextView cacheInfoView; /** - * Destination of the compass, or null (if the compass is used for a waypoint only). + * Destination cache, may be null */ private Geocache cache = null; + /** + * Destination waypoint, may be null + */ + private Waypoint waypoint = null; private Geopoint dstCoords = null; private float cacheHeading = 0; private String description; @@ -188,7 +192,10 @@ public class CompassActivity extends AbstractActionBarActivity { final int id = item.getItemId(); switch (id) { case R.id.menu_map: - if (cache != null) { + if (waypoint != null) { + CGeoMap.startActivityCoords(this, waypoint.getCoords(), waypoint.getWaypointType(), waypoint.getName()); + } + else if (cache != null) { CGeoMap.startActivityGeoCode(this, cache.getGeocode()); } else { @@ -247,8 +254,9 @@ public class CompassActivity extends AbstractActionBarActivity { Log.d("destination set: " + newDescription + " (" + dstCoords + ")"); } - private void setTarget(final @NonNull Waypoint waypoint) { - setTarget(waypoint.getCoords(), waypoint.getName()); + private void setTarget(final @NonNull Waypoint waypointIn) { + waypoint = waypointIn; + setTarget(waypointIn.getCoords(), waypointIn.getName()); } private void setTarget(final Geocache cache) { -- cgit v1.1