[android] #4283 - enable strict mode in test app + fix strict mode warning related to releasing the surface
This commit is contained in:
@@ -1246,11 +1246,13 @@ public class MapView extends FrameLayout {
|
||||
// This class handles TextureView callbacks
|
||||
private class SurfaceTextureListener implements TextureView.SurfaceTextureListener {
|
||||
|
||||
private Surface mSurface;
|
||||
|
||||
// Called when the native surface texture has been created
|
||||
// Must do all EGL/GL ES initialization here
|
||||
@Override
|
||||
public void onSurfaceTextureAvailable(SurfaceTexture surface, int width, int height) {
|
||||
mNativeMapView.createSurface(new Surface(surface));
|
||||
mNativeMapView.createSurface(mSurface = new Surface(surface));
|
||||
mNativeMapView.resizeFramebuffer(width, height);
|
||||
}
|
||||
|
||||
@@ -1261,6 +1263,7 @@ public class MapView extends FrameLayout {
|
||||
if (mNativeMapView != null) {
|
||||
mNativeMapView.destroySurface();
|
||||
}
|
||||
mSurface.release();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.mapbox.mapboxsdk.testapp;
|
||||
|
||||
import android.app.Application;
|
||||
import android.os.StrictMode;
|
||||
|
||||
import com.squareup.leakcanary.LeakCanary;
|
||||
|
||||
@@ -10,5 +11,17 @@ public class MapboxApplication extends Application {
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
LeakCanary.install(this);
|
||||
StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder()
|
||||
.detectDiskReads()
|
||||
.detectDiskWrites()
|
||||
.detectNetwork() // or .detectAll() for all detectable problems
|
||||
.penaltyLog()
|
||||
.build());
|
||||
StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder()
|
||||
.detectLeakedSqlLiteObjects()
|
||||
.detectLeakedClosableObjects()
|
||||
.penaltyLog()
|
||||
.penaltyDeath()
|
||||
.build());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user