FileDocCategorySizeDatePackage
GLTextureViewActivity.javaAPI DocAndroid 5.1 API15954Thu Mar 12 22:22:44 GMT 2015com.android.test.hwui

GLTextureViewActivity

public class GLTextureViewActivity extends android.app.Activity implements TextureView.SurfaceTextureListener

Fields Summary
private RenderThread
mRenderThread
private android.view.TextureView
mTextureView
Constructors Summary
Methods Summary
protected voidonCreate(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 voidonSurfaceTextureAvailable(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 booleanonSurfaceTextureDestroyed(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 voidonSurfaceTextureSizeChanged(android.graphics.SurfaceTexture surface, int width, int height)

    
public voidonSurfaceTextureUpdated(android.graphics.SurfaceTexture surface)