Search in sources :

Example 36 with TextureView

use of android.view.TextureView in project android_frameworks_base by ResurrectionRemix.

the class SingleFrameTextureViewTestActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    TextView preview = new TextView(this);
    preview.setText("This is a preview");
    preview.setBackgroundColor(Color.WHITE);
    mPreview = preview;
    mTextureView = new TextureView(this);
    mTextureView.setSurfaceTextureListener(this);
    FrameLayout content = new FrameLayout(this);
    content.addView(mTextureView, LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
    content.addView(mPreview, LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
    setContentView(content);
}
Also used : FrameLayout(android.widget.FrameLayout) TextView(android.widget.TextView) TextureView(android.view.TextureView)

Example 37 with TextureView

use of android.view.TextureView in project android_frameworks_base by ResurrectionRemix.

the class Crossfade method captureValues.

private void captureValues(TransitionValues transitionValues) {
    View view = transitionValues.view;
    Rect bounds = new Rect(0, 0, view.getWidth(), view.getHeight());
    if (mFadeBehavior != FADE_BEHAVIOR_REVEAL) {
        bounds.offset(view.getLeft(), view.getTop());
    }
    transitionValues.values.put(PROPNAME_BOUNDS, bounds);
    if (Transition.DBG) {
        Log.d(LOG_TAG, "Captured bounds " + transitionValues.values.get(PROPNAME_BOUNDS));
    }
    Bitmap bitmap = Bitmap.createBitmap(view.getWidth(), view.getHeight(), Bitmap.Config.ARGB_8888);
    if (view instanceof TextureView) {
        bitmap = ((TextureView) view).getBitmap();
    } else {
        Canvas c = new Canvas(bitmap);
        view.draw(c);
    }
    transitionValues.values.put(PROPNAME_BITMAP, bitmap);
    // TODO: I don't have resources, can't call the non-deprecated method?
    BitmapDrawable drawable = new BitmapDrawable(bitmap);
    // TODO: lrtb will be wrong if the view has transXY set
    drawable.setBounds(bounds);
    transitionValues.values.put(PROPNAME_DRAWABLE, drawable);
}
Also used : Rect(android.graphics.Rect) Bitmap(android.graphics.Bitmap) Canvas(android.graphics.Canvas) TextureView(android.view.TextureView) BitmapDrawable(android.graphics.drawable.BitmapDrawable) SurfaceView(android.view.SurfaceView) TextureView(android.view.TextureView) View(android.view.View)

Example 38 with TextureView

use of android.view.TextureView in project android_frameworks_base by crdroidandroid.

the class OnTheGoService method setupViews.

private void setupViews(final boolean isRestarting) {
    logDebug("Setup Views, restarting: " + (isRestarting ? "true" : "false"));
    final int cameraType = Settings.System.getInt(getContentResolver(), Settings.System.ON_THE_GO_CAMERA, 0);
    try {
        getCameraInstance(cameraType);
    } catch (Exception exc) {
        // Well, you cant have all in this life..
        logDebug("Exception: " + exc.getMessage());
        createNotification(NOTIFICATION_ERROR);
        stopOnTheGo(true);
    }
    final TextureView mTextureView = new TextureView(this);
    mTextureView.setSurfaceTextureListener(new TextureView.SurfaceTextureListener() {

        @Override
        public void onSurfaceTextureAvailable(SurfaceTexture surfaceTexture, int i, int i2) {
            try {
                if (mCamera != null) {
                    mCamera.setDisplayOrientation(90);
                    mCamera.setPreviewTexture(surfaceTexture);
                    mCamera.startPreview();
                }
            } catch (IOException io) {
                logDebug("IOException: " + io.getMessage());
            }
        }

        @Override
        public void onSurfaceTextureSizeChanged(SurfaceTexture surfaceTexture, int i, int i2) {
        }

        @Override
        public boolean onSurfaceTextureDestroyed(SurfaceTexture surfaceTexture) {
            releaseCamera();
            return true;
        }

        @Override
        public void onSurfaceTextureUpdated(SurfaceTexture surfaceTexture) {
        }
    });
    mOverlay = new FrameLayout(this);
    mOverlay.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
    mOverlay.addView(mTextureView);
    final WindowManager wm = (WindowManager) getSystemService(WINDOW_SERVICE);
    final WindowManager.LayoutParams params = new WindowManager.LayoutParams(WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY, WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL | WindowManager.LayoutParams.FLAG_FULLSCREEN | WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED | WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION | WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS, PixelFormat.TRANSLUCENT);
    wm.addView(mOverlay, params);
    toggleOnTheGoAlpha();
}
Also used : SurfaceTexture(android.graphics.SurfaceTexture) FrameLayout(android.widget.FrameLayout) TextureView(android.view.TextureView) IOException(java.io.IOException) IOException(java.io.IOException) WindowManager(android.view.WindowManager)

Example 39 with TextureView

use of android.view.TextureView in project android_frameworks_base by crdroidandroid.

the class SingleFrameTextureViewTestActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    TextView preview = new TextView(this);
    preview.setText("This is a preview");
    preview.setBackgroundColor(Color.WHITE);
    mPreview = preview;
    mTextureView = new TextureView(this);
    mTextureView.setSurfaceTextureListener(this);
    FrameLayout content = new FrameLayout(this);
    content.addView(mTextureView, LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
    content.addView(mPreview, LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
    setContentView(content);
}
Also used : FrameLayout(android.widget.FrameLayout) TextView(android.widget.TextView) TextureView(android.view.TextureView)

Example 40 with TextureView

use of android.view.TextureView in project android_frameworks_base by crdroidandroid.

the class GetBitmapActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    FrameLayout content = new FrameLayout(this);
    mTextureView = new TextureView(this);
    mTextureView.setSurfaceTextureListener(this);
    Button button = new Button(this);
    button.setText("Copy bitmap to /sdcard/textureview.png");
    button.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            Bitmap b = mTextureView.getBitmap();
            try {
                FileOutputStream out = new FileOutputStream(Environment.getExternalStorageDirectory() + "/textureview.png");
                try {
                    b.compress(Bitmap.CompressFormat.PNG, 100, out);
                } finally {
                    try {
                        out.close();
                    } catch (IOException e) {
                    // Ignore
                    }
                }
            } catch (FileNotFoundException e) {
            // Ignore
            }
        }
    });
    content.addView(mTextureView, new FrameLayout.LayoutParams(500, 400, Gravity.CENTER));
    content.addView(button, new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT, Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM));
    setContentView(content);
}
Also used : Bitmap(android.graphics.Bitmap) Button(android.widget.Button) FrameLayout(android.widget.FrameLayout) FileOutputStream(java.io.FileOutputStream) FileNotFoundException(java.io.FileNotFoundException) TextureView(android.view.TextureView) IOException(java.io.IOException) TextureView(android.view.TextureView) View(android.view.View)

Aggregations

TextureView (android.view.TextureView)44 FrameLayout (android.widget.FrameLayout)34 View (android.view.View)23 Bitmap (android.graphics.Bitmap)22 IOException (java.io.IOException)17 FileNotFoundException (java.io.FileNotFoundException)15 FileOutputStream (java.io.FileOutputStream)15 Button (android.widget.Button)10 BufferedOutputStream (java.io.BufferedOutputStream)10 File (java.io.File)10 SurfaceView (android.view.SurfaceView)7 Canvas (android.graphics.Canvas)6 Rect (android.graphics.Rect)6 BitmapDrawable (android.graphics.drawable.BitmapDrawable)6 TextView (android.widget.TextView)4 SurfaceTexture (android.graphics.SurfaceTexture)3 WindowManager (android.view.WindowManager)2 SuppressLint (android.annotation.SuppressLint)1 Espresso.onView (android.support.test.espresso.Espresso.onView)1 NoMatchingViewException (android.support.test.espresso.NoMatchingViewException)1