Search in sources :

Example 56 with SurfaceView

use of android.view.SurfaceView in project AndroidSDK-RecipeBook by gabu.

the class Recipe064 method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // フルスクリーン表示にします
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
    // タイトルバーを非表示にします
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    // レイアウトとビューを生成して
    mFrameLayout = new FrameLayout(this);
    mCameraView = new SurfaceView(this);
    mOverlayView = new OverlayView(this);
    // SurfaceHolderにコールバックとタイプを指定
    SurfaceHolder holder = mCameraView.getHolder();
    holder.addCallback(mSurfaceHolderCallback);
    holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
    // 重ねます
    mFrameLayout.addView(mCameraView);
    // 後にaddViewしたビューが手前に表示されます。
    mFrameLayout.addView(mOverlayView);
    setContentView(mFrameLayout);
}
Also used : SurfaceHolder(android.view.SurfaceHolder) FrameLayout(android.widget.FrameLayout) SurfaceView(android.view.SurfaceView)

Example 57 with SurfaceView

use of android.view.SurfaceView in project zxing-lib by kennydude.

the class ZXingFragment method onPause.

@Override
public void onPause() {
    if (handler != null) {
        handler.quitSynchronously();
        handler = null;
    }
    // inactivityTimer.onPause();
    // ambientLightManager.stop();
    cameraManager.closeDriver();
    if (!hasSurface) {
        SurfaceView surfaceView = (SurfaceView) getView().findViewById(R.id.preview_view);
        SurfaceHolder surfaceHolder = surfaceView.getHolder();
        surfaceHolder.removeCallback(this);
    }
    super.onPause();
}
Also used : SurfaceHolder(android.view.SurfaceHolder) SurfaceView(android.view.SurfaceView)

Example 58 with SurfaceView

use of android.view.SurfaceView in project coursera-android by aporter.

the class AudioVideoCameraActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    mFrame = (LinearLayout) findViewById(R.id.frame);
    // Disable touches on mFrame
    mFrame.setEnabled(false);
    // Setup touch listener for taking pictures
    mFrame.setOnTouchListener(new View.OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent event) {
            // Only respond to ACTION_UP
            if (event.getActionMasked() == (MotionEvent.ACTION_UP)) {
                // Take picture
                // Pass in shutterCallback and PictureCallback Objects
                mCamera.takePicture(mShutterCallback, null, mPictureCallback);
            }
            return true;
        }
    });
    // Setup SurfaceView for previewing camera image
    SurfaceView surfaceView = (SurfaceView) findViewById(R.id.cameraView);
    // Get SurfaceHolder for accessing the SurfaceView's Surface
    mSurfaceHolder = surfaceView.getHolder();
    // Set callback Object for the SurfaceHolder
    mSurfaceHolder.addCallback(mSurfaceHolderCallback);
}
Also used : SurfaceView(android.view.SurfaceView) View(android.view.View) SurfaceView(android.view.SurfaceView) MotionEvent(android.view.MotionEvent)

Example 59 with SurfaceView

use of android.view.SurfaceView in project grafika by google.

the class ContinuousCaptureActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_continuous_capture);
    SurfaceView sv = (SurfaceView) findViewById(R.id.continuousCapture_surfaceView);
    SurfaceHolder sh = sv.getHolder();
    sh.addCallback(this);
    mHandler = new MainHandler(this);
    mHandler.sendEmptyMessageDelayed(MainHandler.MSG_BLINK_TEXT, 1500);
    mOutputFile = new File(getFilesDir(), "continuous-capture.mp4");
    mSecondsOfVideo = 0.0f;
    updateControls();
}
Also used : SurfaceHolder(android.view.SurfaceHolder) File(java.io.File) SurfaceView(android.view.SurfaceView)

Example 60 with SurfaceView

use of android.view.SurfaceView in project grafika by google.

the class HardwareScalerActivity method surfaceCreated.

@Override
public void surfaceCreated(SurfaceHolder holder) {
    Log.d(TAG, "surfaceCreated holder=" + holder);
    // Grab the view's width.  It's not available before now.
    Rect size = holder.getSurfaceFrame();
    mFullViewWidth = size.width();
    mFullViewHeight = size.height();
    // Configure our fixed-size values.  We want to configure it so that the narrowest
    // dimension (e.g. width when device is in portrait orientation) is equal to the
    // value in SURFACE_DIM, and the other dimension is sized to maintain the same
    // aspect ratio.
    float windowAspect = (float) mFullViewHeight / (float) mFullViewWidth;
    for (int i = 0; i < SURFACE_DIM.length; i++) {
        if (i == SURFACE_SIZE_FULL) {
            // special-case for full size
            mWindowWidthHeight[i][0] = mFullViewWidth;
            mWindowWidthHeight[i][1] = mFullViewHeight;
        } else if (mFullViewWidth < mFullViewHeight) {
            // portrait
            mWindowWidthHeight[i][0] = SURFACE_DIM[i];
            mWindowWidthHeight[i][1] = (int) (SURFACE_DIM[i] * windowAspect);
        } else {
            // landscape
            mWindowWidthHeight[i][0] = (int) (SURFACE_DIM[i] / windowAspect);
            mWindowWidthHeight[i][1] = SURFACE_DIM[i];
        }
    }
    // Some controls include text based on the view dimensions, so update now.
    updateControls();
    SurfaceView sv = (SurfaceView) findViewById(R.id.hardwareScaler_surfaceView);
    mRenderThread = new RenderThread(sv.getHolder());
    mRenderThread.setName("HardwareScaler GL render");
    mRenderThread.start();
    mRenderThread.waitUntilReady();
    RenderHandler rh = mRenderThread.getHandler();
    if (rh != null) {
        rh.sendSetFlatShading(mFlatShadingChecked);
        rh.sendSurfaceCreated();
    }
    // start the draw events
    Choreographer.getInstance().postFrameCallback(this);
}
Also used : Rect(android.graphics.Rect) SurfaceView(android.view.SurfaceView)

Aggregations

SurfaceView (android.view.SurfaceView)93 SurfaceHolder (android.view.SurfaceHolder)45 View (android.view.View)24 SurfaceTexture (android.graphics.SurfaceTexture)16 Surface (android.view.Surface)13 Button (android.widget.Button)12 Intent (android.content.Intent)11 FrameLayout (android.widget.FrameLayout)11 Bitmap (android.graphics.Bitmap)8 TextView (android.widget.TextView)8 FileOutputStream (java.io.FileOutputStream)8 MotionEvent (android.view.MotionEvent)6 ViewGroup (android.view.ViewGroup)6 ImageView (android.widget.ImageView)6 OnClickListener (android.view.View.OnClickListener)5 CameraManager (com.google.zxing.client.android.camera.CameraManager)5 Activity (android.app.Activity)4 PendingIntent (android.app.PendingIntent)4 IntentFilter (android.content.IntentFilter)4 UsbDevice (android.hardware.usb.UsbDevice)4