summaryrefslogtreecommitdiff
path: root/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java
diff options
context:
space:
mode:
Diffstat (limited to 'platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java')
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java40
1 files changed, 16 insertions, 24 deletions
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java
index 77d2ac0e28..d03882b5c7 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java
@@ -296,51 +296,43 @@ public class MapView extends FrameLayout {
mapRenderer = new TextureViewMapRenderer(getContext(), textureView, options.getLocalIdeographFontFamily()) {
@Override
protected void onSurfaceCreated(GL10 gl, EGLConfig config) {
- MapView.this.post(new Runnable() {
- @Override
- public void run() {
- // Initialise only once
- if (mapboxMap == null) {
- initialiseMap();
- mapboxMap.onStart();
- }
- }
- });
-
+ initRenderSurface();
super.onSurfaceCreated(gl, config);
}
};
+
addView(textureView, 0);
} else {
GLSurfaceView glSurfaceView = (GLSurfaceView) findViewById(R.id.surfaceView);
glSurfaceView.setZOrderMediaOverlay(mapboxMapOptions.getRenderSurfaceOnTop());
-
mapRenderer = new GLSurfaceViewMapRenderer(getContext(), glSurfaceView, options.getLocalIdeographFontFamily()) {
@Override
public void onSurfaceCreated(GL10 gl, EGLConfig config) {
- MapView.this.post(new Runnable() {
- @Override
- public void run() {
- // Initialise only once
- if (mapboxMap == null) {
- initialiseMap();
- mapboxMap.onStart();
- }
- }
- });
-
+ initRenderSurface();
super.onSurfaceCreated(gl, config);
}
};
glSurfaceView.setVisibility(View.VISIBLE);
-
}
nativeMapView = new NativeMapView(this, mapRenderer);
nativeMapView.resizeView(getMeasuredWidth(), getMeasuredHeight());
}
+ private void initRenderSurface() {
+ post(new Runnable() {
+ @Override
+ public void run() {
+ // Initialise only when not destroyed and only once
+ if (!destroyed && mapboxMap == null) {
+ initialiseMap();
+ mapboxMap.onStart();
+ }
+ }
+ });
+ }
+
/**
* You must call this method from the parent's Activity#onSaveInstanceState(Bundle)
* or Fragment#onSaveInstanceState(Bundle).