Skip to content

Commit

Permalink
Fix overlay issues in Android introduced in 0.13.1 (react-native-maps…
Browse files Browse the repository at this point in the history
…#1311)

* Update AirMapView.java

* Update AirMapManager.java

* Update AirMapView.java
  • Loading branch information
frmdstryr authored and patricio committed Sep 27, 2017
1 parent ce1b55d commit dded529
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public String getName() {

@Override
protected AirMapView createViewInstance(ThemedReactContext context) {
return new AirMapView(context, this, googleMapOptions);
return new AirMapView(context, this.appContext, this, googleMapOptions);
}

private void emitMapError(ThemedReactContext context, String message, String type) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import android.widget.RelativeLayout;

import com.facebook.react.bridge.LifecycleEventListener;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReadableArray;
import com.facebook.react.bridge.ReadableMap;
import com.facebook.react.bridge.WritableMap;
Expand Down Expand Up @@ -100,10 +101,12 @@ private static boolean contextHasBug(Context context) {
// https://github.com/airbnb/react-native-maps/issues/1147
//
// Doing this allows us to avoid both bugs.
private static Context getNonBuggyContext(ThemedReactContext reactContext) {
private static Context getNonBuggyContext(ThemedReactContext reactContext,
ReactApplicationContext appContext) {
Context superContext = reactContext;

if (contextHasBug(superContext)) {
if (!contextHasBug(appContext.getCurrentActivity())) {
superContext = appContext.getCurrentActivity();
} else if (contextHasBug(superContext)) {
// we have the bug! let's try to find a better context to use
if (!contextHasBug(reactContext.getCurrentActivity())) {
superContext = reactContext.getCurrentActivity();
Expand All @@ -116,9 +119,9 @@ private static Context getNonBuggyContext(ThemedReactContext reactContext) {
return superContext;
}

public AirMapView(ThemedReactContext reactContext, AirMapManager manager,
GoogleMapOptions googleMapOptions) {
super(getNonBuggyContext(reactContext), googleMapOptions);
public AirMapView(ThemedReactContext reactContext, ReactApplicationContext appContext, AirMapManager manager,
GoogleMapOptions googleMapOptions) {
super(getNonBuggyContext(reactContext, appContext), googleMapOptions);

this.manager = manager;
this.context = reactContext;
Expand Down

0 comments on commit dded529

Please sign in to comment.