Skip to content

Instantly share code, notes, and snippets.

@aconbere
Created April 8, 2011 21:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aconbere/910748 to your computer and use it in GitHub Desktop.
Save aconbere/910748 to your computer and use it in GitHub Desktop.
the callee of EscapeThread
public EscapeView(Context context, AttributeSet attrs) {
super(context, attrs);
this.context = context;
SurfaceHolder holder = getHolder();
holder.addCallback(this);
this.thread = new EscapeThread(holder, context);
}
@Override
public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
}
@Override
public void surfaceCreated(SurfaceHolder holder) {
thread.setRunning(true);
thread.run();
}
@Override
public void surfaceDestroyed(SurfaceHolder holder) {
// we have to tell thread to shut down & wait for it to finish, or else
// it might touch the Surface after we return and explode
boolean retry = true;
thread.setRunning(false);
while (retry) {
try {
thread.join();
retry = false;
} catch (InterruptedException e) {
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment