GLTextureViewActivitypublic class GLTextureViewActivity extends android.app.Activity implements TextureView.SurfaceTextureListener
Fields Summary |
---|
private RenderThread | mRenderThread | private android.view.TextureView | mTextureView |
Methods Summary |
---|
protected void | onCreate(android.os.Bundle savedInstanceState)
super.onCreate(savedInstanceState);
mTextureView = new TextureView(this);
mTextureView.setSurfaceTextureListener(this);
mTextureView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Bitmap b = mTextureView.getBitmap(800, 800);
BufferedOutputStream out = null;
try {
File dump = new File(Environment.getExternalStorageDirectory(), "out.png");
out = new BufferedOutputStream(new FileOutputStream(dump));
b.compress(Bitmap.CompressFormat.PNG, 100, out);
} catch (FileNotFoundException e) {
e.printStackTrace();
} finally {
if (out != null) try {
out.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
});
setContentView(mTextureView, new FrameLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT,
Gravity.CENTER));
| public void | onSurfaceTextureAvailable(android.graphics.SurfaceTexture surface, int width, int height)
mRenderThread = new RenderThread(getResources(), surface);
mRenderThread.start();
mTextureView.setCameraDistance(5000);
ObjectAnimator animator = ObjectAnimator.ofFloat(mTextureView, "rotationY", 0.0f, 360.0f);
animator.setRepeatMode(ObjectAnimator.REVERSE);
animator.setRepeatCount(ObjectAnimator.INFINITE);
animator.setDuration(4000);
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
mTextureView.invalidate();
}
});
animator.start();
| public boolean | onSurfaceTextureDestroyed(android.graphics.SurfaceTexture surface)
mRenderThread.finish();
try {
mRenderThread.join();
} catch (InterruptedException e) {
Log.e(RenderThread.LOG_TAG, "Could not wait for render thread");
}
return true;
| public void | onSurfaceTextureSizeChanged(android.graphics.SurfaceTexture surface, int width, int height)
| public void | onSurfaceTextureUpdated(android.graphics.SurfaceTexture surface)
|
|