Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Hardening map destruction #10811

Merged
merged 2 commits into from
Jan 2, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.ZoomButtonsController;

import com.mapbox.mapboxsdk.R;
import com.mapbox.mapboxsdk.annotations.Annotation;
import com.mapbox.mapboxsdk.annotations.MarkerViewManager;
Expand All @@ -37,19 +36,17 @@
import com.mapbox.mapboxsdk.net.ConnectivityReceiver;
import com.mapbox.mapboxsdk.storage.FileSource;
import com.mapbox.services.android.telemetry.MapboxTelemetry;
import timber.log.Timber;

import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.opengles.GL10;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;

import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.opengles.GL10;

import timber.log.Timber;

import static com.mapbox.mapboxsdk.maps.widgets.CompassView.TIME_MAP_NORTH_ANIMATION;
import static com.mapbox.mapboxsdk.maps.widgets.CompassView.TIME_WAIT_IDLE;

Expand Down Expand Up @@ -296,51 +293,43 @@ private void initialiseDrawingSurface(MapboxMapOptions options) {
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() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small nit. But could we rename this to something like onSurfaceCreated? It doesn't really initialise the render surface.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).
Expand Down