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);
}
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();
}
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);
}
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();
}
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);
}
Aggregations