1
1
package com .airbnb .android .react .maps ;
2
2
3
3
import android .view .View ;
4
+ import android .app .Activity ;
4
5
5
6
import com .facebook .react .bridge .Arguments ;
6
7
import com .facebook .react .bridge .ReactContext ;
@@ -40,16 +41,19 @@ public class AirMapManager extends ViewGroupManager<AirMapView> {
40
41
41
42
private ReactContext reactContext ;
42
43
44
+ private Activity reactActivity ;
43
45
private AirMapMarkerManager markerManager ;
44
46
private AirMapPolylineManager polylineManager ;
45
47
private AirMapPolygonManager polygonManager ;
46
48
private AirMapCircleManager circleManager ;
47
49
48
50
public AirMapManager (
51
+ Activity activity ,
49
52
AirMapMarkerManager markerManager ,
50
53
AirMapPolylineManager polylineManager ,
51
54
AirMapPolygonManager polygonManager ,
52
55
AirMapCircleManager circleManager ) {
56
+ this .reactActivity = activity ;
53
57
this .markerManager = markerManager ;
54
58
this .polylineManager = polylineManager ;
55
59
this .polygonManager = polygonManager ;
@@ -64,14 +68,14 @@ public String getName() {
64
68
@ Override
65
69
protected AirMapView createViewInstance (ThemedReactContext context ) {
66
70
reactContext = context ;
67
- AirMapView view = new AirMapView (context , this );
68
71
69
72
try {
70
- MapsInitializer .initialize (context . getApplicationContext () );
73
+ MapsInitializer .initialize (reactActivity );
71
74
} catch (Exception e ) {
72
75
e .printStackTrace ();
73
76
emitMapError ("Map initialize error" , "map_init_error" );
74
77
}
78
+ AirMapView view = new AirMapView (context , reactActivity , this );
75
79
76
80
return view ;
77
81
}
@@ -278,7 +282,6 @@ public void updateExtraData(AirMapView view, Object extraData) {
278
282
}
279
283
280
284
public void pushEvent (View view , String name , WritableMap data ) {
281
- ReactContext reactContext = (ReactContext ) view .getContext ();
282
285
reactContext .getJSModule (RCTEventEmitter .class )
283
286
.receiveEvent (view .getId (), name , data );
284
287
}
0 commit comments