use of android.view.SurfaceHolder in project zxingfragmentlib by mitoyarzun.
the class BarCodeScannerFragment method startScan.
public void startScan() {
if (cameraManager != null) {
Log.e(TAG, "startScan: scan already started.");
return;
}
cameraManager = new CameraManager(getActivity());
cameraManager.setManualCameraId(getRequestedCameraId());
viewfinderView = (ViewfinderView) getView().findViewById(R.id.viewfinder_view);
viewfinderView.setCameraManager(cameraManager);
handler = null;
lastResult = null;
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getActivity());
//
// if (prefs.getBoolean(PreferencesActivity.KEY_DISABLE_AUTO_ORIENTATION, true)) {
// //noinspection ResourceType
// getActivity().setRequestedOrientation(getCurrentOrientation());
// } else {
// getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE);
// }
SurfaceView surfaceView = (SurfaceView) getView().findViewById(R.id.preview_view);
SurfaceHolder surfaceHolder = surfaceView.getHolder();
surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
if (hasSurface) {
// The activity was paused but not stopped, so the surface still exists. Therefore
// surfaceCreated() won't be called, so init the camera here.
initCamera(surfaceHolder);
} else {
// Install the callback and wait for surfaceCreated() to init the camera.
surfaceHolder.addCallback(this);
}
beepManager.updatePrefs();
ambientLightManager.start(cameraManager);
inactivityTimer.onResume();
decodeFormats = null;
characterSet = null;
}
use of android.view.SurfaceHolder in project zxingfragmentlib by mitoyarzun.
the class BarCodeScannerFragment method stopScan.
public void stopScan() {
if (cameraManager == null) {
Log.e(TAG, "stopScan: scan already stopped");
return;
}
if (handler != null) {
handler.quitSynchronously();
handler = null;
}
inactivityTimer.onPause();
ambientLightManager.stop();
beepManager.close();
cameraManager.closeDriver();
cameraManager = null;
if (!hasSurface) {
SurfaceView surfaceView = (SurfaceView) getView().findViewById(R.id.preview_view);
SurfaceHolder surfaceHolder = surfaceView.getHolder();
surfaceHolder.removeCallback(this);
}
}
use of android.view.SurfaceHolder in project zxing-lib by kennydude.
the class ZXingFragment method onResume.
@SuppressWarnings("deprecation")
@Override
public void onResume() {
super.onResume();
// Setup camera view
cameraManager = new CameraManager(getActivity().getApplication());
cameraManager.setManualFramingRect(getView().getWidth(), getView().getHeight());
viewfinderView = (ViewfinderView) getView().findViewById(R.id.viewfinder_view);
viewfinderView.setCameraManager(cameraManager);
SurfaceView surfaceView = (SurfaceView) getView().findViewById(R.id.preview_view);
SurfaceHolder surfaceHolder = surfaceView.getHolder();
if (hasSurface) {
// The activity was paused but not stopped, so the surface still
// exists. Therefore
// surfaceCreated() won't be called, so init the camera here.
initCamera(surfaceHolder);
} else {
// Install the callback and wait for surfaceCreated() to init the
// camera.
surfaceHolder.addCallback(this);
surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
}
}
use of android.view.SurfaceHolder in project android_frameworks_base by ParanoidAndroid.
the class CameraTest method checkTakePicture.
private void checkTakePicture() {
SurfaceHolder mSurfaceHolder;
try {
mSurfaceHolder = MediaFrameworkTest.mSurfaceView.getHolder();
mCamera.setPreviewDisplay(mSurfaceHolder);
Log.v(TAG, "Start preview");
mCamera.startPreview();
waitForPreviewDone();
mCamera.setPreviewCallback(null);
mCamera.takePicture(mShutterCallback, mRawPictureCallback, mJpegPictureCallback);
waitForSnapshotDone();
} catch (Exception e) {
Log.v(TAG, e.toString());
}
}
use of android.view.SurfaceHolder in project android_frameworks_base by ParanoidAndroid.
the class CameraFunctionalTest method testFunctionalCameraFlashModes.
/**
* Functional test iterating on the various flash modes (on, off, auto, torch)
*/
@LargeTest
public void testFunctionalCameraFlashModes() throws Exception {
try {
SurfaceHolder surfaceHolder = MediaFrameworkTest.mSurfaceView.getHolder();
Parameters params = mCameraTestHelper.getCameraParameters();
List<String> supportedFlashModes = params.getSupportedFlashModes();
assertNotNull("No flash modes supported", supportedFlashModes);
for (int i = 0; i < supportedFlashModes.size(); i++) {
runOnLooper(new Runnable() {
@Override
public void run() {
mCameraTestHelper.setupCameraTest();
}
});
Log.v(TAG, "Setting flash mode to " + supportedFlashModes.get(i));
params.setFlashMode(supportedFlashModes.get(i));
mCameraTestHelper.setParameters(params);
mCameraTestHelper.startCameraPreview(surfaceHolder);
mCameraTestHelper.capturePhoto();
}
mCameraTestHelper.cleanupTestImages();
} catch (Exception e) {
Log.e(TAG, e.toString());
fail("Camera flash mode test Exception");
}
}
Aggregations