From 56755fd80af2505ccef1d6ccf2ef77251a6c12c7 Mon Sep 17 00:00:00 2001 From: Roman Romanov Date: Wed, 25 Jan 2017 14:46:50 +0400 Subject: [PATCH] =?UTF-8?q?[android]=20Don=E2=80=99t=20cancel=20routing=20?= =?UTF-8?q?when=20building=20status=20code=20NEED=5FMORE=5FMAPS?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../routing/BaseRoutingErrorDialogFragment.java | 6 +++++- .../mapswithme/maps/routing/ResultCodesHelper.java | 5 +++++ .../mapswithme/maps/routing/RoutingController.java | 13 ++++++++----- .../maps/routing/RoutingErrorDialogFragment.java | 2 ++ 4 files changed, 20 insertions(+), 6 deletions(-) diff --git a/android/src/com/mapswithme/maps/routing/BaseRoutingErrorDialogFragment.java b/android/src/com/mapswithme/maps/routing/BaseRoutingErrorDialogFragment.java index bda356c1a5..5879c782d3 100644 --- a/android/src/com/mapswithme/maps/routing/BaseRoutingErrorDialogFragment.java +++ b/android/src/com/mapswithme/maps/routing/BaseRoutingErrorDialogFragment.java @@ -41,6 +41,7 @@ abstract class BaseRoutingErrorDialogFragment extends BaseMwmDialogFragment private boolean mCancelRoute = true; boolean mCancelled; + boolean mNeedMoreMaps; void beforeDialogCreated(AlertDialog.Builder builder) {} void bindGroup(View view) {} @@ -85,9 +86,12 @@ abstract class BaseRoutingErrorDialogFragment extends BaseMwmDialogFragment @Override public void onDismiss(DialogInterface dialog) { - if (mCancelled && mCancelRoute) + if (!mNeedMoreMaps && mCancelled && mCancelRoute) RoutingController.get().cancel(); + if (mNeedMoreMaps && mCancelled) + RoutingController.get().finishBuild(); + super.onDismiss(dialog); } diff --git a/android/src/com/mapswithme/maps/routing/ResultCodesHelper.java b/android/src/com/mapswithme/maps/routing/ResultCodesHelper.java index 84b21da173..13aed02efa 100644 --- a/android/src/com/mapswithme/maps/routing/ResultCodesHelper.java +++ b/android/src/com/mapswithme/maps/routing/ResultCodesHelper.java @@ -111,4 +111,9 @@ class ResultCodesHelper resultCode == NEED_MORE_MAPS || (resultCode == ROUTE_NOT_FOUND && missingCount > 0)); } + + static boolean isNeedMoreMaps(int resultCode) + { + return resultCode == NEED_MORE_MAPS; + } } diff --git a/android/src/com/mapswithme/maps/routing/RoutingController.java b/android/src/com/mapswithme/maps/routing/RoutingController.java index 3237a4179d..cbdf8adc52 100644 --- a/android/src/com/mapswithme/maps/routing/RoutingController.java +++ b/android/src/com/mapswithme/maps/routing/RoutingController.java @@ -123,11 +123,7 @@ public class RoutingController mContainsCachedResult = true; if (mLastResultCode == ResultCodesHelper.NO_ERROR) - { - mCachedRoutingInfo = Framework.nativeGetRouteFollowingInfo(); - setBuildState(BuildState.BUILT); - mLastBuildProgress = 100; - } + finishBuild(); processRoutingEvent(); } @@ -135,6 +131,13 @@ public class RoutingController } }; + void finishBuild() + { + mCachedRoutingInfo = Framework.nativeGetRouteFollowingInfo(); + setBuildState(BuildState.BUILT); + mLastBuildProgress = 100; + } + @SuppressWarnings("FieldCanBeLocal") private final Framework.RoutingProgressListener mRoutingProgressListener = new Framework.RoutingProgressListener() { diff --git a/android/src/com/mapswithme/maps/routing/RoutingErrorDialogFragment.java b/android/src/com/mapswithme/maps/routing/RoutingErrorDialogFragment.java index 40e0db20f2..984b06d1ff 100644 --- a/android/src/com/mapswithme/maps/routing/RoutingErrorDialogFragment.java +++ b/android/src/com/mapswithme/maps/routing/RoutingErrorDialogFragment.java @@ -34,6 +34,8 @@ public class RoutingErrorDialogFragment extends BaseRoutingErrorDialogFragment if (ResultCodesHelper.isDownloadable(mResultCode, mMissingMaps.size())) builder.setPositiveButton(R.string.download, null); + + mNeedMoreMaps = ResultCodesHelper.isNeedMoreMaps(mResultCode); } private View addMessage(View frame)