Esempio n. 1
0
 public void stopCamera() {
   if (mCamera != null) {
     mPreviewFrame.removeView(mPreview);
   }
   Log.d(TAG, "stopping camera");
   mCameraHandler.sendEmptyMessage(STOP_PREVIEW);
   mCameraHandler.sendEmptyMessage(RELEASE);
   mHandler.removeCallbacks(cameraFocusRunner);
   mPreviewing = false;
 }
Esempio n. 2
0
 public void setFlashOn(boolean on) {
   // You have camera in your device
   if (hasCameraFlash()) {
     if (on) {
       mFlashOn = true;
       mCameraHandler.sendEmptyMessage(FLASH_ON);
     } else {
       mFlashOn = false;
       mCameraHandler.sendEmptyMessage(FLASH_OFF);
     }
   }
 }
 @Override
 public CameraManager.CameraProxy cameraOpen(
     Handler handler, int cameraId, CameraOpenErrorCallback callback) {
   mCameraHandler
       .obtainMessage(
           OPEN_CAMERA,
           cameraId,
           0,
           CameraOpenErrorCallbackForward.getNewInstance(handler, callback))
       .sendToTarget();
   mCameraHandler.waitDone();
   if (mCamera != null) {
     return new AndroidCameraProxyImpl();
   } else {
     return null;
   }
 }
Esempio n. 4
0
 private void finishOpenCamera() {
   mPreview = new CameraSurfacePreview(mFragment.getActivity(), mCamera);
   mCameraHandler.sendEmptyMessage(SETUP);
   mPreviewing = true;
   mHandler.post(
       new Runnable() {
         public void run() {
           mPreviewFrame.addView(mPreview);
         }
       });
 }
Esempio n. 5
0
 private void startupTheCamera() {
   if (mFragment.getActivity() == null) {
     return;
   }
   final int cameraIndex = pickCamera();
   if (cameraIndex < 0) {
     return;
   }
   mCameraHandler.post(
       new Runnable() {
         public void run() {
           try {
             Log.d(TAG, "Opening Camera");
             mCamera = Camera.open(cameraIndex);
             finishOpenCamera();
           } catch (Exception e) {
             Log.e(TAG, "Camera Does Not exist", e);
             mHandler.postDelayed(mCameraStartRunner, 500);
           }
         }
       });
 }
Esempio n. 6
0
 @Override
 public void run() {
   mCameraHandler.sendEmptyMessage(AUTO_FOCUS);
   mHandler.postDelayed(cameraFocusRunner, FOCUS_MILLIS);
 }
Esempio n. 7
0
 public void stopScanning() {
   mCameraHandler.sendEmptyMessage(PREVIEW_OFF);
 }
Esempio n. 8
0
 public void startScanning() {
   mCameraHandler.sendEmptyMessage(PREVIEW_ON);
 }
 @Override
 protected void onDestroy() {
   Log.d(TAG, "onDestroy");
   super.onDestroy();
   mCameraHandler.invalidateHandler(); // paranoia
 }