summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortobrun <tobrun.van.nuland@gmail.com>2018-01-02 11:30:48 +0100
committerTobrun <tobrun@mapbox.com>2018-01-10 13:14:04 +0100
commit1985bb83f40b1f4ef3433137fb5434956cd265ac (patch)
tree354a9a752d877b3dcdca7534b9deb3df1ebbae1d
parented84dca3344b9d53cc60adb49eb92c8b7fd645fc (diff)
downloadqtlocation-mapboxgl-1985bb83f40b1f4ef3433137fb5434956cd265ac.tar.gz
[android] - refactor surface destruction NPE fix
-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).