Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Commit

Permalink
[android] - synchronize display and context initalisation with create…
Browse files Browse the repository at this point in the history
… surface to avoid EGL bad surface (#8759)
  • Loading branch information
tobrun authored Apr 18, 2017
1 parent ddecdec commit 8e9eaaa
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 16 deletions.
1 change: 1 addition & 0 deletions platform/android/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Mapbox welcomes participation and contributions from everyone. If you'd like to
* OfflineRegion are validated if the bounds is found in the world bounds, else onError will be invoked [#8517](https://github.com/mapbox/mapbox-gl-native/pull/8517)
* Polygon holes [#8557](https://github.com/mapbox/mapbox-gl-native/pull/8557) and [#8722](https://github.com/mapbox/mapbox-gl-native/pull/8722)
* Custom location source [#8710](https://github.com/mapbox/mapbox-gl-native/pull/8710)
* Ensure surface is created after display and context [#8759](https://github.com/mapbox/mapbox-gl-native/pull/8759)

## 5.0.2 - April 3, 2017

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
public class MapView extends FrameLayout {

private NativeMapView nativeMapView;
private boolean textureMode;
private boolean destroyed;
private boolean hasSurface;

Expand Down Expand Up @@ -105,12 +106,14 @@ private void initialise(@NonNull final Context context, @NonNull final MapboxMap
return;
}

// determine render surface
textureMode = options.getTextureMode();

// inflate view
View view = LayoutInflater.from(context).inflate(R.layout.mapbox_mapview_internal, this);
CompassView compassView = (CompassView) view.findViewById(R.id.compassView);
MyLocationView myLocationView = (MyLocationView) view.findViewById(R.id.userLocationView);
ImageView attrView = (ImageView) view.findViewById(R.id.attributionView);
initalizeDrawingSurface(context, options);

// add accessibility support
setContentDescription(context.getString(R.string.mapbox_mapActionDescription));
Expand Down Expand Up @@ -167,18 +170,6 @@ private void initialise(@NonNull final Context context, @NonNull final MapboxMap
mapboxMap.initialise(context, options);
}

private void initalizeDrawingSurface(Context context, MapboxMapOptions options) {
if (options.getTextureMode()) {
TextureView textureView = new TextureView(context);
textureView.setSurfaceTextureListener(new SurfaceTextureListener());
addView(textureView, 0);
} else {
SurfaceView surfaceView = (SurfaceView) findViewById(R.id.surfaceView);
surfaceView.getHolder().addCallback(new SurfaceCallback());
surfaceView.setVisibility(View.VISIBLE);
}
}

//
// Lifecycle events
//
Expand All @@ -202,11 +193,22 @@ public void onCreate(@Nullable Bundle savedInstanceState) {
mapboxMap.onRestoreInstanceState(savedInstanceState);
}

// Initialize EGL
initialiseDrawingSurface(textureMode);
addOnMapChangedListener(mapCallback = new MapCallback(mapboxMap));
}

private void initialiseDrawingSurface(boolean textureMode) {
nativeMapView.initializeDisplay();
nativeMapView.initializeContext();

addOnMapChangedListener(mapCallback = new MapCallback(mapboxMap));
if (textureMode) {
TextureView textureView = new TextureView(getContext());
textureView.setSurfaceTextureListener(new SurfaceTextureListener());
addView(textureView, 0);
} else {
SurfaceView surfaceView = (SurfaceView) findViewById(R.id.surfaceView);
surfaceView.getHolder().addCallback(new SurfaceCallback());
surfaceView.setVisibility(View.VISIBLE);
}
}

/**
Expand Down

0 comments on commit 8e9eaaa

Please sign in to comment.