Пример #1
0
 @Override
 public void onDestroy() {
   super.onDestroy();
   if (camera != null) {
     camera.release();
     camera = null;
   }
 }
Пример #2
0
 @Override
 public void onPause() {
   super.onPause();
   if (orientationListener != null) {
     orientationListener.disable();
     orientationListener = null;
   }
 }
Пример #3
0
 @Override
 public void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   boolean useFrontCamera = getArguments().getBoolean(FRONT_CAMERA, false);
   camera = getCameraInstance(useFrontCamera);
   if (camera == null) {
     return;
   }
   initScreenParams();
   parameters = camera.getParameters();
   zoomRatios = parameters.getZoomRatios();
   zoomIndex = minZoomIndex = 0;
   maxZoomIndex = parameters.getMaxZoom();
   previewSizes = buildPreviewSizesRatioMap(parameters.getSupportedPreviewSizes());
   pictureSizes = buildPictureSizesRatioMap(parameters.getSupportedPictureSizes());
   List<String> sceneModes = parameters.getSupportedSceneModes();
   if (sceneModes != null) {
     for (String mode : sceneModes) {
       if (mode.equals(Camera.Parameters.SCENE_MODE_HDR)) {
         supportedHDR = true;
         break;
       }
     }
   }
   // it returns false positive
   /*getActivity().getApplicationContext().getPackageManager()
   .hasSystemFeature(PackageManager.FEATURE_CAMERA_FLASH);*/
   List<String> flashModes = parameters.getSupportedFlashModes();
   if (flashModes == null || flashModes.size() <= 1) {
     /* Device has no flash */
     supportedFlash = false;
   } else {
     supportedFlash = true;
   }
   if (CameraConst.DEBUG) {
     Timber.d("PictureSizesRatioMap:");
     for (Ratio r : pictureSizes.keySet()) {
       Timber.d(r.toString() + ":");
       for (Quality q : pictureSizes.get(r).keySet()) {
         Camera.Size size = pictureSizes.get(r).get(q);
         if (size != null) {
           Timber.d(q.toString() + ": " + size.width + "x" + size.height);
         }
       }
     }
   }
   expandParams(getArguments());
   initParams();
 }
Пример #4
0
 @Override
 public void onResume() {
   super.onResume();
   if (camera != null) {
     try {
       camera.reconnect();
     } catch (IOException e) {
       e.printStackTrace();
     }
   }
   if (orientationListener == null) {
     initOrientationListener();
   }
   orientationListener.enable();
 }