mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-17 11:35:08 -04:00
simplify changing surfaces code for android
This commit is contained in:
parent
a15c65512c
commit
87926a82f4
@ -212,7 +212,8 @@ public class MainActivity extends Activity implements SurfaceHolder.Callback2 {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPause() {
|
protected void onPause() {
|
||||||
detachSurface();
|
// can't use null.. TODO is there a better way?
|
||||||
|
setContentView(new View(this));
|
||||||
super.onPause();
|
super.onPause();
|
||||||
pushCmd(CMD_APP_PAUSE);
|
pushCmd(CMD_APP_PAUSE);
|
||||||
}
|
}
|
||||||
@ -316,17 +317,16 @@ public class MainActivity extends Activity implements SurfaceHolder.Callback2 {
|
|||||||
final Semaphore winDestroyedSem = new Semaphore(0, true);
|
final Semaphore winDestroyedSem = new Semaphore(0, true);
|
||||||
public void surfaceDestroyed(SurfaceHolder holder) {
|
public void surfaceDestroyed(SurfaceHolder holder) {
|
||||||
Log.i("CC_WIN", "win destroyed " + holder.getSurface());
|
Log.i("CC_WIN", "win destroyed " + holder.getSurface());
|
||||||
// per the android docs for SurfaceHolder.Callback
|
Log.i("CC_WIN", "cur view " + curView);
|
||||||
// "If you have a rendering thread that directly accesses the surface, you must ensure
|
holder.removeCallback(this);
|
||||||
// that thread is no longer touching the Surface before returning from this function."
|
|
||||||
Log.i("CC_WIN", "cur holder " + holder);
|
|
||||||
Log.i("CC_WIN", "cur view" + curView.getHolder());
|
|
||||||
curView.getHolder().removeCallback(this); // or just holder??
|
|
||||||
|
|
||||||
//08-02 21:03:02.967: E/BufferQueueProducer(1350): [SurfaceView - com.classicube.ClassiCube/com.classicube.MainActivity#0] disconnect: not connected (req=2)
|
//08-02 21:03:02.967: E/BufferQueueProducer(1350): [SurfaceView - com.classicube.ClassiCube/com.classicube.MainActivity#0] disconnect: not connected (req=2)
|
||||||
//08-02 21:03:02.968: E/SurfaceFlinger(1350): Failed to find layer (SurfaceView - com.classicube.ClassiCube/com.classicube.MainActivity#0) in layer parent (no-parent).
|
//08-02 21:03:02.968: E/SurfaceFlinger(1350): Failed to find layer (SurfaceView - com.classicube.ClassiCube/com.classicube.MainActivity#0) in layer parent (no-parent).
|
||||||
|
|
||||||
pushCmd(CMD_WIN_DESTROYED);
|
pushCmd(CMD_WIN_DESTROYED);
|
||||||
|
// per the android docs for SurfaceHolder.Callback
|
||||||
|
// "If you have a rendering thread that directly accesses the surface, you must ensure
|
||||||
|
// that thread is no longer touching the Surface before returning from this function."
|
||||||
try {
|
try {
|
||||||
winDestroyedSem.acquire();
|
winDestroyedSem.acquire();
|
||||||
} catch (InterruptedException e) { }
|
} catch (InterruptedException e) { }
|
||||||
@ -352,11 +352,6 @@ public class MainActivity extends Activity implements SurfaceHolder.Callback2 {
|
|||||||
curView.requestFocus();
|
curView.requestFocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
void detachSurface() {
|
|
||||||
// can't use null.. TODO is there a better way?
|
|
||||||
setContentView(new View(this));
|
|
||||||
}
|
|
||||||
|
|
||||||
class LauncherView extends SurfaceView {
|
class LauncherView extends SurfaceView {
|
||||||
|
|
||||||
public LauncherView(Context context) { super(context); }
|
public LauncherView(Context context) { super(context); }
|
||||||
@ -376,7 +371,6 @@ public class MainActivity extends Activity implements SurfaceHolder.Callback2 {
|
|||||||
// So just destroy the current surface and make a new one
|
// So just destroy the current surface and make a new one
|
||||||
runOnUiThread(new Runnable() {
|
runOnUiThread(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
detachSurface();
|
|
||||||
attachSurface();
|
attachSurface();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user