Exemplo n.º 1
0
  /**
   * This is called immediately before a surface is being destroyed. After returning from this call,
   * you should no longer try to access this surface. 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.
   *
   * @param holder The SurfaceHolder whose surface is being destroyed.
   */
  @Override
  public void surfaceDestroyed(SurfaceHolder holder) {
    boolean retry = true;

    loop.isRunning(false);
    while (retry) {
      try {
        loop.join();
        retry = false;
      } catch (InterruptedException e) {
        e.printStackTrace();
      }
    }
  }
Exemplo n.º 2
0
  @Override
  public void surfaceDestroyed(SurfaceHolder holder) {
    // simply copied from sample application LunarLander:
    // 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;
    loop.isRunning(false);
    while (retry) {
      try {
        loop.join();
        retry = false;
      } catch (InterruptedException e) {
        // we will try it again and again...
      }
    }
  }