[android] - synchronize display and context initalisation with create surface to avoid EGL bad surface (#8759)
This commit is contained in:
@@ -62,6 +62,7 @@ import java.util.List;
|
||||
public class MapView extends FrameLayout {
|
||||
|
||||
private NativeMapView nativeMapView;
|
||||
private boolean textureMode;
|
||||
private boolean destroyed;
|
||||
private boolean hasSurface;
|
||||
|
||||
@@ -105,12 +106,14 @@ public class MapView extends FrameLayout {
|
||||
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));
|
||||
@@ -167,18 +170,6 @@ public class MapView extends FrameLayout {
|
||||
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
|
||||
//
|
||||
@@ -202,11 +193,22 @@ public class MapView extends FrameLayout {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user