From ab5f935b57db7255d1ca939c296f2d869a56a3cc Mon Sep 17 00:00:00 2001 From: tobrun Date: Fri, 15 Mar 2019 14:06:59 +0100 Subject: [android] - hook GLSurfaceViewMapRenderer into surfaceCreated callback, don't destroy map renderer when surface is destroyed as it can be recreated later --- .../renderer/glsurfaceview/GLSurfaceViewMapRenderer.java | 13 +++++-------- .../maps/renderer/textureview/TextureViewRenderThread.java | 1 - 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/renderer/glsurfaceview/GLSurfaceViewMapRenderer.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/renderer/glsurfaceview/GLSurfaceViewMapRenderer.java index 9d9a7bd2d4..6eeb148283 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/renderer/glsurfaceview/GLSurfaceViewMapRenderer.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/renderer/glsurfaceview/GLSurfaceViewMapRenderer.java @@ -2,10 +2,8 @@ package com.mapbox.mapboxsdk.maps.renderer.glsurfaceview; import android.content.Context; import android.opengl.GLSurfaceView; - import android.support.annotation.NonNull; import android.view.SurfaceHolder; - import com.mapbox.mapboxsdk.maps.renderer.MapRenderer; import com.mapbox.mapboxsdk.maps.renderer.egl.EGLConfigChooser; @@ -25,8 +23,6 @@ public class GLSurfaceViewMapRenderer extends MapRenderer implements GLSurfaceVi @NonNull private final GLSurfaceView glSurfaceView; - private boolean requestDestroy; - public GLSurfaceViewMapRenderer(Context context, GLSurfaceView glSurfaceView, String localIdeographFontFamily) { @@ -42,9 +38,13 @@ public class GLSurfaceViewMapRenderer extends MapRenderer implements GLSurfaceVi @Override public void surfaceDestroyed(SurfaceHolder holder) { - requestDestroy = true; + onSurfaceDestroyed(); } + @Override + public void surfaceCreated(SurfaceHolder holder) { + onSurfaceCreated(null, null); + } }); } @@ -60,9 +60,6 @@ public class GLSurfaceViewMapRenderer extends MapRenderer implements GLSurfaceVi @Override public void onDestroy() { - if (requestDestroy) { - onSurfaceDestroyed(); - } super.onDestroy(); } diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/renderer/textureview/TextureViewRenderThread.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/renderer/textureview/TextureViewRenderThread.java index 96d5e9e943..165b15a512 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/renderer/textureview/TextureViewRenderThread.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/renderer/textureview/TextureViewRenderThread.java @@ -197,7 +197,6 @@ class TextureViewRenderThread extends Thread implements TextureView.SurfaceTextu if (destroySurface) { eglHolder.destroySurface(); destroySurface = false; - mapRenderer.onSurfaceDestroyed(); break; } -- cgit v1.2.1