diff --git a/android/src/com/mapswithme/maps/MwmActivity.java b/android/src/com/mapswithme/maps/MwmActivity.java index aef419b4eb..dfddcec114 100644 --- a/android/src/com/mapswithme/maps/MwmActivity.java +++ b/android/src/com/mapswithme/maps/MwmActivity.java @@ -1135,20 +1135,10 @@ public class MwmActivity extends BaseMwmFragmentActivity return; } - if (closeMenu() || closePlacePage() || closeSearchToolbar(true, true) || - closeBookmarkCategoryToolbar() || closeSidePanel() || closePositionChooser()) - { - return; - } - RoutingController routingController = RoutingController.get(); - if (routingController.isNavigating()) - { - routingController.resetToPlanningState(); - return; - } - - if (!routingController.cancel()) + if (!closeMenu() && !closePlacePage() && !closeSearchToolbar(true, true) && + !closeBookmarkCategoryToolbar() && !closeSidePanel() && !closePositionChooser() && + !routingController.resetToPlanningStateIfNavigating() && !routingController.cancel()) { try { diff --git a/android/src/com/mapswithme/maps/routing/RoutingController.java b/android/src/com/mapswithme/maps/routing/RoutingController.java index 84f4caafd2..056aedfd0d 100644 --- a/android/src/com/mapswithme/maps/routing/RoutingController.java +++ b/android/src/com/mapswithme/maps/routing/RoutingController.java @@ -514,12 +514,20 @@ public class RoutingController implements Initializable backToPlaningStateIfNavigating(); } - public void resetToPlanningState() + /** + * @return False if not navigating, true otherwise + */ + public boolean resetToPlanningStateIfNavigating() { - build(); - if (mContainer != null) - mContainer.onResetToPlanningState(); - backToPlaningStateIfNavigating(); + if (isNavigating()) + { + build(); + if (mContainer != null) + mContainer.onResetToPlanningState(); + backToPlaningStateIfNavigating(); + return true; + } + return false; } private void backToPlaningStateIfNavigating()