summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortobrun <tobrun.van.nuland@gmail.com>2019-05-10 09:48:57 +0200
committerTobrun <tobrun.van.nuland@gmail.com>2019-05-10 14:29:12 +0200
commit1b8eb9a7c6c5d82b847caf924e565070f9b8933c (patch)
treea71142c46e398e173716a6fa10a44be021d59602
parent8675d11e5e2a0be1aa17616f4aaabbfc169f6659 (diff)
downloadqtlocation-mapboxgl-1b8eb9a7c6c5d82b847caf924e565070f9b8933c.tar.gz
[android] - use atomic boolean for hasSurface, check if renderer is created by validating if mapboxMap isn't null when invoking MapView#onLowMemory
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java2
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/renderer/MapRenderer.java6
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/renderer/glsurfaceview/GLSurfaceViewMapRenderer.java7
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/renderer/textureview/TextureViewMapRenderer.java4
4 files changed, 11 insertions, 8 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 a2c49b0d8f..42c607360d 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
@@ -503,7 +503,7 @@ public class MapView extends FrameLayout implements NativeMapView.ViewCallback {
*/
@UiThread
public void onLowMemory() {
- if (nativeMapView != null && !destroyed) {
+ if (nativeMapView != null && mapboxMap != null && !destroyed ) {
nativeMapView.onLowMemory();
}
}
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/renderer/MapRenderer.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/renderer/MapRenderer.java
index d8cfb1641a..715d05df6f 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/renderer/MapRenderer.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/renderer/MapRenderer.java
@@ -9,6 +9,8 @@ import com.mapbox.mapboxsdk.log.Logger;
import com.mapbox.mapboxsdk.maps.MapboxMap;
import com.mapbox.mapboxsdk.storage.FileSource;
+import java.util.concurrent.atomic.AtomicBoolean;
+
import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.opengles.GL10;
@@ -32,7 +34,7 @@ public abstract class MapRenderer implements MapRendererScheduler {
private long nativePtr = 0;
private double expectedRenderTime = 0;
private MapboxMap.OnFpsChangedListener onFpsChangedListener;
- protected boolean hasSurface;
+ protected AtomicBoolean hasSurface = new AtomicBoolean();
public MapRenderer(@NonNull Context context, String localIdeographFontFamily) {
float pixelRatio = context.getResources().getDisplayMetrics().density;
@@ -165,6 +167,6 @@ public abstract class MapRenderer implements MapRendererScheduler {
* @return returns if renderer has a surface, false otherwise
*/
public boolean hasSurface() {
- return hasSurface;
+ return hasSurface.get();
}
}
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 aa36dace76..9ddee8d1ad 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
@@ -4,6 +4,7 @@ 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;
@@ -38,13 +39,13 @@ public class GLSurfaceViewMapRenderer extends MapRenderer implements GLSurfaceVi
@Override
public void surfaceCreated(SurfaceHolder holder) {
super.surfaceCreated(holder);
- hasSurface = true;
+ hasSurface.set(true);
}
@Override
public void surfaceDestroyed(SurfaceHolder holder) {
super.surfaceDestroyed(holder);
- hasSurface = false;
+ hasSurface.set(false);
nativeReset();
}
});
@@ -102,7 +103,7 @@ public class GLSurfaceViewMapRenderer extends MapRenderer implements GLSurfaceVi
*/
@Override
public void requestRender() {
- if (!hasSurface) {
+ if (!hasSurface.get()) {
return;
}
glSurfaceView.requestRender();
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/renderer/textureview/TextureViewMapRenderer.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/renderer/textureview/TextureViewMapRenderer.java
index eade1e6aac..b60316e586 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/renderer/textureview/TextureViewMapRenderer.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/renderer/textureview/TextureViewMapRenderer.java
@@ -43,7 +43,7 @@ public class TextureViewMapRenderer extends MapRenderer {
@Override
protected void onSurfaceCreated(GL10 gl, EGLConfig config) {
super.onSurfaceCreated(gl, config);
- hasSurface = true;
+ hasSurface.set(true);
}
/**
@@ -59,7 +59,7 @@ public class TextureViewMapRenderer extends MapRenderer {
*/
@Override
protected void onSurfaceDestroyed() {
- hasSurface = false;
+ hasSurface.set(false);
super.onSurfaceDestroyed();
}