From 0beb61f54c3a891eb293d2ca14003ee33676953e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B0=D0=BD=D0=B4=D1=80=20?= =?UTF-8?q?=D0=97=D0=B0=D1=86=D0=B5=D0=BF=D0=B8=D0=BD?= Date: Thu, 3 Aug 2017 19:25:02 +0300 Subject: [PATCH] [android] Refoctored proccessing the incoming intent Restoring the route should take place only if there is no any incoming intent, i.e. when activity is launched in usual manner (by user) --- .../src/com/mapswithme/maps/MwmActivity.java | 28 ++++++++++++++----- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/android/src/com/mapswithme/maps/MwmActivity.java b/android/src/com/mapswithme/maps/MwmActivity.java index da46274982..25cc849237 100644 --- a/android/src/com/mapswithme/maps/MwmActivity.java +++ b/android/src/com/mapswithme/maps/MwmActivity.java @@ -507,11 +507,10 @@ public class MwmActivity extends BaseMwmFragmentActivity mSearchController = new FloatingSearchToolbarController(this); mSearchController.setVisibilityListener(this); - processIntent(getIntent()); - SharingHelper.prepare(); - SearchEngine.INSTANCE.addListener(this); + SharingHelper.prepare(); + //TODO: uncomment after correct visible rect calculation. //mVisibleRectMeasurer = new VisibleRectMeasurer(new VisibleRectListener() { // @Override @@ -520,7 +519,11 @@ public class MwmActivity extends BaseMwmFragmentActivity // } //}); //getWindow().getDecorView().addOnLayoutChangeListener(mVisibleRectMeasurer); - mTasks.add(new RestoreRouteTask()); + boolean isConsumed = processIntent(getIntent()); + // If the map activity is launched by any incoming intent (deeplink, update maps event, etc) + // we haven't to try restoring the route. + if (!isConsumed) + addTask(new RestoreRouteTask()); } private void initViews() @@ -1028,25 +1031,36 @@ public class MwmActivity extends BaseMwmFragmentActivity protected void onNewIntent(Intent intent) { super.onNewIntent(intent); + setIntent(intent); processIntent(intent); } - private void processIntent(Intent intent) + private boolean processIntent(Intent intent) { if (intent == null) - return; + return false; if (intent.hasExtra(EXTRA_TASK)) + { addTask(intent); - else if (intent.hasExtra(EXTRA_UPDATE_COUNTRIES)) + return true; + } + + if (intent.hasExtra(EXTRA_UPDATE_COUNTRIES)) + { showDownloader(true); + return true; + } HotelsFilter filter = intent.getParcelableExtra(SearchActivity.EXTRA_HOTELS_FILTER); if (mFilterController != null) { mFilterController.show(filter != null || !TextUtils.isEmpty(SearchEngine.getQuery()), true); mFilterController.setFilter(filter); + return filter != null; } + + return false; } private void addTask(Intent intent)