react-native-maps 1.26.9 → 1.26.11
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.
|
@@ -152,6 +152,12 @@ public class MarkerManager extends ViewGroupManager<MapMarker> implements RNMaps
|
|
|
152
152
|
view.setUpdated(true);
|
|
153
153
|
}
|
|
154
154
|
|
|
155
|
+
@Override
|
|
156
|
+
public void onDropViewInstance(MapMarker view) {
|
|
157
|
+
super.onDropViewInstance(view);
|
|
158
|
+
view.doDestroy();
|
|
159
|
+
}
|
|
160
|
+
|
|
155
161
|
@Override
|
|
156
162
|
public void setCalloutOffset(MapMarker view, @Nullable ReadableMap value) {
|
|
157
163
|
|
|
@@ -17,11 +17,13 @@ import android.animation.TypeEvaluator;
|
|
|
17
17
|
import android.os.Handler;
|
|
18
18
|
import android.os.Looper;
|
|
19
19
|
|
|
20
|
+
import androidx.annotation.NonNull;
|
|
20
21
|
import androidx.annotation.Nullable;
|
|
21
22
|
|
|
22
23
|
import com.facebook.common.references.CloseableReference;
|
|
23
24
|
import com.facebook.datasource.DataSource;
|
|
24
25
|
import com.facebook.drawee.backends.pipeline.Fresco;
|
|
26
|
+
import com.facebook.drawee.controller.AbstractDraweeController;
|
|
25
27
|
import com.facebook.drawee.controller.BaseControllerListener;
|
|
26
28
|
import com.facebook.drawee.controller.ControllerListener;
|
|
27
29
|
import com.facebook.drawee.drawable.ScalingUtils;
|
|
@@ -29,6 +31,8 @@ import com.facebook.drawee.generic.GenericDraweeHierarchy;
|
|
|
29
31
|
import com.facebook.drawee.generic.GenericDraweeHierarchyBuilder;
|
|
30
32
|
import com.facebook.drawee.interfaces.DraweeController;
|
|
31
33
|
import com.facebook.drawee.view.DraweeHolder;
|
|
34
|
+
import com.facebook.drawee.view.DraweeView;
|
|
35
|
+
import com.facebook.fresco.ui.common.ControllerListener2;
|
|
32
36
|
import com.facebook.imagepipeline.core.ImagePipeline;
|
|
33
37
|
import com.facebook.imagepipeline.image.CloseableImage;
|
|
34
38
|
import com.facebook.imagepipeline.image.CloseableStaticBitmap;
|
|
@@ -56,6 +60,8 @@ import com.rnmaps.fabric.event.OnDragStartEvent;
|
|
|
56
60
|
import com.rnmaps.fabric.event.OnPressEvent;
|
|
57
61
|
import com.rnmaps.fabric.event.OnSelectEvent;
|
|
58
62
|
|
|
63
|
+
import java.lang.ref.SoftReference;
|
|
64
|
+
import java.lang.reflect.Method;
|
|
59
65
|
import java.util.Map;
|
|
60
66
|
|
|
61
67
|
public class MapMarker extends MapFeature {
|
|
@@ -102,6 +108,10 @@ public class MapMarker extends MapFeature {
|
|
|
102
108
|
private String imageUri;
|
|
103
109
|
private boolean loadingImage;
|
|
104
110
|
|
|
111
|
+
private SoftReference<MarkerManager.Collection> markerCollectionRef;
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
|
|
105
115
|
private final DraweeHolder<?> logoHolder;
|
|
106
116
|
private ImageManager.OnImageLoadedListener imageLoadedListener;
|
|
107
117
|
private DataSource<CloseableReference<CloseableImage>> dataSource;
|
|
@@ -204,6 +214,16 @@ public class MapMarker extends MapFeature {
|
|
|
204
214
|
update(false);
|
|
205
215
|
}
|
|
206
216
|
|
|
217
|
+
public void doDestroy() {
|
|
218
|
+
MarkerManager.Collection collection = markerCollectionRef != null
|
|
219
|
+
? markerCollectionRef.get()
|
|
220
|
+
: null;
|
|
221
|
+
|
|
222
|
+
if (collection != null) {
|
|
223
|
+
this.removeFromMap(collection);
|
|
224
|
+
}
|
|
225
|
+
markerCollectionRef = null;
|
|
226
|
+
}
|
|
207
227
|
public String getIdentifier() {
|
|
208
228
|
return this.identifier;
|
|
209
229
|
}
|
|
@@ -324,7 +344,7 @@ public class MapMarker extends MapFeature {
|
|
|
324
344
|
}
|
|
325
345
|
|
|
326
346
|
updateMarkerIcon();
|
|
327
|
-
if (updated > 0){
|
|
347
|
+
if (updated > 0) {
|
|
328
348
|
updated--;
|
|
329
349
|
}
|
|
330
350
|
return true;
|
|
@@ -449,9 +469,67 @@ public class MapMarker extends MapFeature {
|
|
|
449
469
|
if (!(child instanceof MapCallout)) {
|
|
450
470
|
hasCustomMarkerView = true;
|
|
451
471
|
updateTracksViewChanges();
|
|
472
|
+
hackToHandleDraweeLifecycle(child);
|
|
452
473
|
}
|
|
453
474
|
update(true);
|
|
454
475
|
}
|
|
476
|
+
private void hackToHandleDraweeLifecycle(View child){
|
|
477
|
+
if (child instanceof DraweeView<?>) {
|
|
478
|
+
try {
|
|
479
|
+
DraweeView draweeView = (DraweeView) child;
|
|
480
|
+
|
|
481
|
+
Method onAttachMethod = DraweeView.class.getDeclaredMethod("onAttachedToWindow");
|
|
482
|
+
onAttachMethod.setAccessible(true);
|
|
483
|
+
onAttachMethod.invoke(child);
|
|
484
|
+
|
|
485
|
+
Handler mainHandler = new Handler(Looper.getMainLooper());
|
|
486
|
+
|
|
487
|
+
if (draweeView.getController() instanceof AbstractDraweeController<?,?>){
|
|
488
|
+
AbstractDraweeController abstractController = (AbstractDraweeController) draweeView.getController();
|
|
489
|
+
|
|
490
|
+
abstractController.addControllerListener2(new ControllerListener2() {
|
|
491
|
+
@Override
|
|
492
|
+
public void onSubmit(@NonNull String s, @Nullable Object o, @Nullable Extras extras) {
|
|
493
|
+
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
@Override
|
|
497
|
+
public void onFinalImageSet(@NonNull String s, @Nullable Object o, @Nullable Extras extras) {
|
|
498
|
+
mainHandler.postDelayed(() -> update(true), ((GenericDraweeHierarchy) draweeView.getHierarchy()).getFadeDuration());
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
@Override
|
|
502
|
+
public void onIntermediateImageSet(@NonNull String s, @Nullable Object o) {
|
|
503
|
+
mainHandler.post(() -> update(true));
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
@Override
|
|
507
|
+
public void onIntermediateImageFailed(@NonNull String s) {
|
|
508
|
+
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
@Override
|
|
512
|
+
public void onFailure(@NonNull String s, @Nullable Throwable throwable, @Nullable Extras extras) {
|
|
513
|
+
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
@Override
|
|
517
|
+
public void onRelease(@NonNull String s, @Nullable Extras extras) {
|
|
518
|
+
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
@Override
|
|
522
|
+
public void onEmptyEvent(@Nullable Object o) {
|
|
523
|
+
|
|
524
|
+
}
|
|
525
|
+
});
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
} catch (Exception e) {
|
|
529
|
+
e.printStackTrace();
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
}
|
|
455
533
|
|
|
456
534
|
@Override
|
|
457
535
|
public void requestLayout() {
|
|
@@ -484,6 +562,7 @@ public class MapMarker extends MapFeature {
|
|
|
484
562
|
public void addToMap(Object collection) {
|
|
485
563
|
MarkerManager.Collection markerCollection = (MarkerManager.Collection) collection;
|
|
486
564
|
marker = markerCollection.addMarker(getMarkerOptions());
|
|
565
|
+
this.markerCollectionRef = new SoftReference<>(markerCollection);
|
|
487
566
|
updateTracksViewChanges();
|
|
488
567
|
}
|
|
489
568
|
|
|
@@ -556,13 +635,13 @@ public class MapMarker extends MapFeature {
|
|
|
556
635
|
} else {
|
|
557
636
|
marker.setInfoWindowAnchor(0.5f, 0);
|
|
558
637
|
}
|
|
559
|
-
updated +=1;
|
|
638
|
+
updated += 1;
|
|
560
639
|
}
|
|
561
640
|
|
|
562
641
|
public void update(int width, int height) {
|
|
563
642
|
this.width = width;
|
|
564
643
|
this.height = height;
|
|
565
|
-
updated +=1;
|
|
644
|
+
updated += 1;
|
|
566
645
|
updateTracksViewChanges();
|
|
567
646
|
clearDrawableCache();
|
|
568
647
|
update(true);
|
|
@@ -740,10 +819,10 @@ public class MapMarker extends MapFeature {
|
|
|
740
819
|
);
|
|
741
820
|
}
|
|
742
821
|
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
822
|
+
@Override
|
|
823
|
+
protected void onLayout(boolean changed, int l, int t, int r, int b) {
|
|
824
|
+
super.onLayout(changed, l, t, r, b);
|
|
825
|
+
this.height = b - t;
|
|
826
|
+
this.width = r - l;
|
|
827
|
+
}
|
|
749
828
|
}
|
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.26.
|
|
8
|
+
"version": "1.26.11",
|
|
9
9
|
"license": "MIT",
|
|
10
10
|
"scripts": {
|
|
11
11
|
"lint": "eslint . --max-warnings 0",
|