react-native-maps 1.26.15 → 1.26.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -14,6 +14,7 @@ import androidx.lifecycle.DefaultLifecycleObserver;
14
14
  import androidx.lifecycle.LifecycleOwner;
15
15
 
16
16
  import android.os.Bundle;
17
+ import android.util.Log;
17
18
  import android.view.GestureDetector;
18
19
  import android.view.MotionEvent;
19
20
  import android.view.View;
@@ -228,16 +229,16 @@ public class MapView extends com.google.android.gms.maps.MapView implements Goog
228
229
 
229
230
  @Override
230
231
  public void onPause(LifecycleOwner owner) {
231
- super.onPause();
232
232
  if (hasPermissions() && map != null) {
233
233
  //noinspection MissingPermission
234
234
  map.setMyLocationEnabled(false);
235
235
  }
236
236
  synchronized (MapView.this) {
237
- if (!destroyed) {
237
+ if (!paused) {
238
+ super.onPause();
238
239
  MapView.this.onPause();
240
+ paused = true;
239
241
  }
240
- paused = true;
241
242
  }
242
243
  }
243
244
 
@@ -317,6 +318,12 @@ public class MapView extends com.google.android.gms.maps.MapView implements Goog
317
318
  @Override
318
319
  protected void onAttachedToWindow() {
319
320
  super.onAttachedToWindow();
321
+
322
+ // Reset lifecycle flags when reattaching
323
+ synchronized (this) {
324
+ paused = false;
325
+ }
326
+
320
327
  attachLifecycleObserver();
321
328
  if (savedMapState != null) {
322
329
  super.onCreate(savedMapState);
@@ -338,12 +345,33 @@ public class MapView extends com.google.android.gms.maps.MapView implements Goog
338
345
  // Override onDetachedFromWindow to detach lifecycle observer
339
346
  @Override
340
347
  protected void onDetachedFromWindow() {
341
- if (savedMapState == null) {
342
- savedMapState = new Bundle();
348
+ synchronized (this) {
349
+ // Save instance state if not already saved and map is ready
350
+ if (map != null && isMapReady) {
351
+ try {
352
+ if (savedMapState == null) {
353
+ savedMapState = new Bundle();
354
+ }
355
+ super.onSaveInstanceState(savedMapState);
356
+ } catch (Exception e) {
357
+ Log.e("MapView", "Error saving state in onDetachedFromWindow: " + e.getMessage());
358
+ // Continue with cleanup even if state saving fails
359
+ }
360
+ }
361
+
362
+ // Pause safely if not already paused
363
+ if (!paused) {
364
+ onPause();
365
+ }
343
366
  }
344
- super.onSaveInstanceState(savedMapState);
345
- super.onPause();
346
- super.onStop();
367
+
368
+ // These operations don't need synchronization
369
+ try {
370
+ onStop();
371
+ } catch (Exception e) {
372
+ Log.e("MapView", "Error during stop in onDetachedFromWindow: " + e.getMessage());
373
+ }
374
+
347
375
  savedFeatures = new ArrayList<>(features);
348
376
  features.clear();
349
377
  shouldRestorePadding = true;
package/package.json CHANGED
@@ -7,7 +7,7 @@
7
7
  "types": "dist/src/index.d.ts",
8
8
  "author": "Leland Richardson <leland.m.richardson@gmail.com>",
9
9
  "homepage": "https://github.com/react-native-maps/react-native-maps#readme",
10
- "version": "1.26.15",
10
+ "version": "1.26.16",
11
11
  "license": "MIT",
12
12
  "scripts": {
13
13
  "lint": "eslint . --max-warnings 0",