From 62db098ee256578d3f3c8bf7bf1eda26848b685a Mon Sep 17 00:00:00 2001 From: Arnaud Vergnet Date: Mon, 15 May 2023 11:19:07 +0200 Subject: [PATCH] [android] improve pp attach country behavior Signed-off-by: Arnaud Vergnet --- .../app/organicmaps/widget/placepage/PlacePageView.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/android/src/app/organicmaps/widget/placepage/PlacePageView.java b/android/src/app/organicmaps/widget/placepage/PlacePageView.java index 21ee2ebb45..2a18f47247 100644 --- a/android/src/app/organicmaps/widget/placepage/PlacePageView.java +++ b/android/src/app/organicmaps/widget/placepage/PlacePageView.java @@ -246,7 +246,6 @@ public class PlacePageView extends Fragment implements View.OnClickListener, super.onStart(); mViewModel.getMapObject().observe(requireActivity(), this); LocationHelper.INSTANCE.addListener(this); - setCurrentCountry(); } @Override @@ -260,7 +259,7 @@ public class PlacePageView extends Fragment implements View.OnClickListener, private void setCurrentCountry() { - if (mCurrentCountry != null || mMapObject == null) + if (mCurrentCountry != null) return; String country = MapManager.nativeGetSelectedCountry(); if (country != null && !RoutingController.get().isNavigating()) @@ -601,11 +600,11 @@ public class PlacePageView extends Fragment implements View.OnClickListener, { if (mapObject == null) return; + // Starting the download will fire this callback but the object will be the same + // Detaching the country in that case will crash the app if (!mapObject.sameAs(mMapObject)) - { detachCountry(); - setCurrentCountry(); - } + setCurrentCountry(); mMapObject = mapObject;