@@ -102,6 +102,7 @@ class ExploreMapFragment : CommonsDaggerSupportFragment(), ExploreMapContract.Vi
102102 private var prevLatitude = 0.0
103103 private var prevLongitude = 0.0
104104 private var recentlyCameFromNearbyMap = false
105+ private var shouldPerformMapReadyActionsOnResume = false
105106 private var presenter: ExploreMapPresenter ? = null
106107 private var binding: FragmentExploreMapBinding ? = null
107108 var mediaList: MutableList <Media >? = null
@@ -281,6 +282,10 @@ class ExploreMapFragment : CommonsDaggerSupportFragment(), ExploreMapContract.Vi
281282 requireActivity().registerReceiver(broadcastReceiver, intentFilter)
282283 }
283284 setSearchThisAreaButtonVisibility(false )
285+ if (shouldPerformMapReadyActionsOnResume) {
286+ shouldPerformMapReadyActionsOnResume = false
287+ performMapReadyActions()
288+ }
284289 }
285290
286291 override fun onPause () {
@@ -292,6 +297,11 @@ class ExploreMapFragment : CommonsDaggerSupportFragment(), ExploreMapContract.Vi
292297 }
293298
294299 fun requestLocationIfNeeded () {
300+ if (isResumed) {
301+ performMapReadyActions()
302+ } else {
303+ shouldPerformMapReadyActionsOnResume = true
304+ }
295305 if (! isVisible) return // skips if not visible to user
296306 if (locationPermissionsHelper!! .checkLocationPermission(requireActivity())) {
297307 if (locationPermissionsHelper!! .isLocationAccessToAppsTurnedOn()) {
@@ -361,7 +371,7 @@ class ExploreMapFragment : CommonsDaggerSupportFragment(), ExploreMapContract.Vi
361371 if (isCameFromNearbyMap) {
362372 moveCameraToPosition(
363373 GeoPoint (prevLatitude, prevLongitude),
364- prevZoom,
374+ prevZoom.coerceIn( 1.0 , 22.0 ) ,
365375 1L
366376 )
367377 } else {
@@ -379,12 +389,11 @@ class ExploreMapFragment : CommonsDaggerSupportFragment(), ExploreMapContract.Vi
379389 // get fragment arguments
380390 if (arguments != null ) {
381391 with (requireArguments()) {
382- prevZoom = getDouble(" prev_zoom" )
383- prevLatitude = getDouble(" prev_latitude" )
384- prevLongitude = getDouble(" prev_longitude" )
392+ if (containsKey( " prev_zoom " )) prevZoom = getDouble(" prev_zoom" )
393+ if (containsKey( " prev_latitude " )) prevLatitude = getDouble(" prev_latitude" )
394+ if (containsKey( " prev_longitude " )) prevLongitude = getDouble(" prev_longitude" )
385395 }
386396 }
387-
388397 setRecentlyCameFromNearbyMap(isCameFromNearbyMap)
389398 }
390399
0 commit comments