Add Map::pause/resume

Fixed bug after switching apps
This commit is contained in:
Leith Bade
2014-11-09 22:36:37 +11:00
parent b3e3c21129
commit 28d66bb6f8
9 changed files with 214 additions and 43 deletions

View File

@@ -373,6 +373,7 @@ public class MapView extends SurfaceView {
}
mNativeMapView.initializeDisplay();
mNativeMapView.initializeContext();
}
// Called when we need to save instance state
@@ -392,6 +393,7 @@ public class MapView extends SurfaceView {
// Must be called from Activity onDestroy
public void onDestroy() {
Log.v(TAG, "onDestroy");
mNativeMapView.terminateContext();
mNativeMapView.terminateDisplay();
}
@@ -399,21 +401,22 @@ public class MapView extends SurfaceView {
// Must be called from Activity onStart
public void onStart() {
Log.v(TAG, "onStart");
mNativeMapView.initializeContext();
mNativeMapView.pause();
mNativeMapView.start();
}
// Called when we need to terminate the GL context
// Must be called from Activity onPause
public void onStop() {
Log.v(TAG, "onStop");
mNativeMapView.terminateContext();
mNativeMapView.stop();
}
// Called when we need to stop the render thread
// Must be called from Activity onPause
public void onPause() {
Log.v(TAG, "onPause");
mNativeMapView.stop();
mNativeMapView.pause();
}
// Called when we need to start the render thread
@@ -421,7 +424,7 @@ public class MapView extends SurfaceView {
public void onResume() {
Log.v(TAG, "onResume");
mNativeMapView.start();
mNativeMapView.resume();
}
// This class handles SurfaceHolder callbacks
@@ -464,6 +467,8 @@ public class MapView extends SurfaceView {
}
}
// TODO examine how GLSurvaceView hadles attach/detach from window
// Called when view is no longer connected
@Override
protected void onDetachedFromWindow() {

View File

@@ -80,6 +80,14 @@ class NativeMapView {
nativeStop(mNativeMapViewPtr);
}
public void pause() {
nativePause(mNativeMapViewPtr);
}
public void resume() {
nativeResume(mNativeMapViewPtr);
}
public void run() {
nativeRun(mNativeMapViewPtr);
}
@@ -420,6 +428,10 @@ class NativeMapView {
private native void nativeStop(long nativeMapViewPtr);
private native void nativePause(long nativeMapViewPtr);
private native void nativeResume(long nativeMapViewPtr);
private native void nativeRun(long nativeMapViewPtr);
private native void nativeRerender(long nativeMapViewPtr);