From 3887ad0636a45ac8d121a41b0c9717cbaea6b5b8 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 7 Jul 2014 12:04:24 +0300 Subject: [PATCH] fixed bug with navigation not continue after reaching point --- .../RoutePointsPlugin.java | 33 ++++++++++--------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/routepointsnavigation/RoutePointsPlugin.java b/OsmAnd/src/net/osmand/plus/routepointsnavigation/RoutePointsPlugin.java index 36667e9a4e..d6bdf4bd0d 100644 --- a/OsmAnd/src/net/osmand/plus/routepointsnavigation/RoutePointsPlugin.java +++ b/OsmAnd/src/net/osmand/plus/routepointsnavigation/RoutePointsPlugin.java @@ -51,6 +51,9 @@ public class RoutePointsPlugin extends OsmandPlugin { private RoutePointsLayer routePointsLayer; + private RoutePoint lastReachedPoint; + + public RoutePointsPlugin(OsmandApplication app) { ApplicationMode.regWidget("route_steps", ApplicationMode.CAR, ApplicationMode.DEFAULT); this.app = app; @@ -78,7 +81,10 @@ public class RoutePointsPlugin extends OsmandPlugin { btnY.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { - currentRoute.navigateToNextPoint(true); + if (lastReachedPoint != null){ + lastReachedPoint.setDelivered(true); + lastReachedPoint = null; + } FrameLayout layout = (FrameLayout) mapActivity.getLayout(); layout.removeView(deliveredView); } @@ -89,7 +95,10 @@ public class RoutePointsPlugin extends OsmandPlugin { btnN.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { - currentRoute.navigateToNextPoint(false); + if (lastReachedPoint != null){ + lastReachedPoint.setDelivered(false); + lastReachedPoint = null; + } FrameLayout layout = (FrameLayout) mapActivity.getLayout(); layout.removeView(deliveredView); } @@ -100,10 +109,16 @@ public class RoutePointsPlugin extends OsmandPlugin { @Override public boolean destinationReached() { if (currentRoute != null) { + if (currentRoute.currentPoints != null && !currentRoute.currentPoints.isEmpty()){ + lastReachedPoint = currentRoute.currentPoints.get(0); + } FrameLayout layout = (FrameLayout) mapActivity.getLayout(); FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.WRAP_CONTENT); params.gravity = Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL; layout.addView(deliveredView, params); + //if it's possible to navigate to next point - navigation continues + return !currentRoute.navigateToNextPoint(); + } return true; @@ -463,20 +478,6 @@ public class RoutePointsPlugin extends OsmandPlugin { return null; } - public boolean navigateToNextPoint(boolean delivered) { - if (currentPoints.isEmpty()) { - return false; - } - - RoutePoint rp = currentPoints.get(0); - if (rp.isNextNavigate) { - rp.setDelivered(delivered); - return navigateToNextPoint(); - } - - return false; - } - public void saveGPXAsync() { new AsyncTask() {