Fix - 2136(c)

This commit is contained in:
Alexey Kulish 2016-01-14 11:59:33 +03:00
parent c3004c08c8
commit 108984926e

View file

@ -10,6 +10,7 @@ import net.osmand.plus.TargetPointsHelper.TargetPoint;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.mapcontextmenu.MenuBuilder;
import net.osmand.plus.mapcontextmenu.MenuController;
import net.osmand.plus.routing.RoutingHelper;
import net.osmand.util.Algorithms;
public class TargetPointMenuController extends MenuController {
@ -19,10 +20,13 @@ public class TargetPointMenuController extends MenuController {
public TargetPointMenuController(OsmandApplication app, MapActivity mapActivity, PointDescription pointDescription, TargetPoint targetPoint) {
super(new MenuBuilder(app), pointDescription, mapActivity);
this.targetPoint = targetPoint;
final TargetPointsHelper targetPointsHelper = getMapActivity().getMyApplication().getTargetPointsHelper();
final int intermediatePointsCount = targetPointsHelper.getIntermediatePoints().size();
RoutingHelper routingHelper = getMapActivity().getMyApplication().getRoutingHelper();
final boolean nav = routingHelper.isRoutePlanningMode() || routingHelper.isFollowingMode();
leftTitleButtonController = new TitleButtonController() {
@Override
public void buttonPressed() {
TargetPointsHelper targetPointsHelper = getMapActivity().getMyApplication().getTargetPointsHelper();
TargetPoint tp = getTargetPoint();
if(tp.intermediate) {
targetPointsHelper.removeWayPoint(true, tp.index);
@ -30,10 +34,18 @@ public class TargetPointMenuController extends MenuController {
targetPointsHelper.removeWayPoint(true, -1);
}
getMapActivity().getContextMenu().close();
if (nav && intermediatePointsCount == 0) {
getMapActivity().getMapActions().stopNavigationWithoutConfirm();
}
}
};
leftTitleButtonController.caption = getMapActivity().getString(R.string.shared_string_delete);
leftTitleButtonController.leftIconId = R.drawable.ic_action_delete_dark;
if (nav && intermediatePointsCount == 0) {
leftTitleButtonController.caption = getMapActivity().getString(R.string.cancel_navigation);
leftTitleButtonController.leftIconId = R.drawable.ic_action_remove_dark;
} else {
leftTitleButtonController.caption = getMapActivity().getString(R.string.shared_string_delete);
leftTitleButtonController.leftIconId = R.drawable.ic_action_delete_dark;
}
}
@Override