react-native-maps 1.24.2 → 1.24.3
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.
|
@@ -132,6 +132,9 @@ public class MapView extends com.google.android.gms.maps.MapView implements Goog
|
|
|
132
132
|
private int cameraMoveReason = 0;
|
|
133
133
|
private MapMarker selectedMarker;
|
|
134
134
|
|
|
135
|
+
private LifecycleOwner currentLifecycleOwner;
|
|
136
|
+
private boolean isLifecycleObserverAttached = false;
|
|
137
|
+
|
|
135
138
|
private static final String[] PERMISSIONS = new String[]{
|
|
136
139
|
"android.permission.ACCESS_FINE_LOCATION", "android.permission.ACCESS_COARSE_LOCATION"};
|
|
137
140
|
|
|
@@ -250,10 +253,6 @@ public class MapView extends com.google.android.gms.maps.MapView implements Goog
|
|
|
250
253
|
GoogleMapOptions googleMapOptions) {
|
|
251
254
|
super(context, googleMapOptions);
|
|
252
255
|
this.context = context;
|
|
253
|
-
Activity activity = context.getCurrentActivity();
|
|
254
|
-
if (activity instanceof LifecycleOwner) {
|
|
255
|
-
((LifecycleOwner) activity).getLifecycle().addObserver(this);
|
|
256
|
-
}
|
|
257
256
|
super.getMapAsync(this);
|
|
258
257
|
|
|
259
258
|
final MapView view = this;
|
|
@@ -309,6 +308,38 @@ public class MapView extends com.google.android.gms.maps.MapView implements Goog
|
|
|
309
308
|
|
|
310
309
|
}
|
|
311
310
|
|
|
311
|
+
@Override
|
|
312
|
+
protected void onAttachedToWindow() {
|
|
313
|
+
super.onAttachedToWindow();
|
|
314
|
+
attachLifecycleObserver();
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
// Override onDetachedFromWindow to detach lifecycle observer
|
|
318
|
+
@Override
|
|
319
|
+
protected void onDetachedFromWindow() {
|
|
320
|
+
detachLifecycleObserver();
|
|
321
|
+
super.onDetachedFromWindow();
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
// Method to attach lifecycle observer
|
|
325
|
+
private void attachLifecycleObserver() {
|
|
326
|
+
Activity activity = context.getCurrentActivity();
|
|
327
|
+
if (activity instanceof LifecycleOwner && !isLifecycleObserverAttached) {
|
|
328
|
+
currentLifecycleOwner = (LifecycleOwner) activity;
|
|
329
|
+
currentLifecycleOwner.getLifecycle().addObserver(this);
|
|
330
|
+
isLifecycleObserverAttached = true;
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
// Method to detach lifecycle observer
|
|
335
|
+
private void detachLifecycleObserver() {
|
|
336
|
+
if (currentLifecycleOwner != null && isLifecycleObserverAttached) {
|
|
337
|
+
currentLifecycleOwner.getLifecycle().removeObserver(this);
|
|
338
|
+
isLifecycleObserverAttached = false;
|
|
339
|
+
currentLifecycleOwner = null;
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
|
|
312
343
|
public double[][] getMarkersFrames(boolean onlyVisible) {
|
|
313
344
|
|
|
314
345
|
LatLngBounds.Builder builder = new LatLngBounds.Builder();
|
|
@@ -689,10 +720,9 @@ public class MapView extends com.google.android.gms.maps.MapView implements Goog
|
|
|
689
720
|
}
|
|
690
721
|
destroyed = true;
|
|
691
722
|
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
}
|
|
723
|
+
// Detach lifecycle observer before destroying
|
|
724
|
+
detachLifecycleObserver();
|
|
725
|
+
|
|
696
726
|
if (!paused) {
|
|
697
727
|
onPause();
|
|
698
728
|
paused = true;
|
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"main": "src/index.ts",
|
|
6
6
|
"author": "Leland Richardson <leland.m.richardson@gmail.com>",
|
|
7
7
|
"homepage": "https://github.com/react-native-maps/react-native-maps#readme",
|
|
8
|
-
"version": "1.24.
|
|
8
|
+
"version": "1.24.3",
|
|
9
9
|
"license": "MIT",
|
|
10
10
|
"scripts": {
|
|
11
11
|
"lint": "eslint . --max-warnings 0",
|