Android Open Source - Blufpoker My Surface Thread






From Project

Back to project page Blufpoker.

License

The source code is released under:

Apache License

If you think the Android project Blufpoker listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package org.stofkat.blufpoker;
// w  w  w.j  a v a2 s  .  c  o m
import android.annotation.SuppressLint;
import android.graphics.Canvas;
import android.view.SurfaceHolder;

public class MySurfaceThread extends Thread {
  private SurfaceHolder myThreadSurfaceHolder;
  private MySurfaceView myThreadSurfaceView;
  private boolean myThreadRun = false;
  
  public MySurfaceThread(SurfaceHolder surfaceHolder, MySurfaceView surfaceView) {
    myThreadSurfaceHolder = surfaceHolder;
    myThreadSurfaceView = surfaceView;
  }
  
  public void setRunning(boolean b) {
    myThreadRun = b;
  }

  @SuppressLint("WrongCall")
  @Override
  public void run() {
    // TODO Auto-generated method stub
    while(myThreadRun){
      Canvas c = null;

      try{
        c = myThreadSurfaceHolder.lockCanvas(null);
        synchronized (myThreadSurfaceHolder){
          myThreadSurfaceView.onDraw(c);
        }
        sleep(100);
      } catch (InterruptedException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
      finally{
        // do this in a finally so that if an exception is thrown
        // during the above, we don't leave the Surface in an
        // inconsistent state
        if (c != null) {
          myThreadSurfaceHolder.unlockCanvasAndPost(c);
        }
      }
    }
  }
}




Java Source Code List

org.stofkat.blufpoker.AndroidMergeSurfaceView.java
org.stofkat.blufpoker.BlufPokerActivity.java
org.stofkat.blufpoker.IntentKeys.java
org.stofkat.blufpoker.MyGLRenderer.java
org.stofkat.blufpoker.MyGLSurfaceView.java
org.stofkat.blufpoker.MySurfaceThread.java
org.stofkat.blufpoker.MySurfaceView.java
org.stofkat.blufpoker.OpenGLES20Activity.java
org.stofkat.blufpoker.Square.java
org.stofkat.blufpoker.Test.java
org.stofkat.blufpoker.Triangle.java
org.stofkat.blufpoker.util.SystemUiHiderBase.java
org.stofkat.blufpoker.util.SystemUiHiderHoneycomb.java
org.stofkat.blufpoker.util.SystemUiHider.java