Class CameraController

    • Constructor Summary

      Constructors 
      Constructor Description
      CameraController​(androidx.fragment.app.Fragment fragment, androidx.camera.view.PreviewView previewView)
      Creates a basic CameraController that displays its preview to a view.
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      boolean cameraPermissionsGranted()
      Checks if all required permissions are granted
      void onDestroy()
      Shut down the camera when it's no longer needed
      protected abstract void setupCamera​(com.google.common.util.concurrent.ListenableFuture<androidx.camera.lifecycle.ProcessCameraProvider> cameraProviderFuture)
      Adds in the camera's functionality
      void startCamera()
      Starts the camera and binds it's preview to the PreviewView UI element.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • cameraExecutor

        protected java.util.concurrent.ExecutorService cameraExecutor
      • fragment

        protected androidx.fragment.app.Fragment fragment
      • previewView

        protected androidx.camera.view.PreviewView previewView
      • REQUEST_CODE_PERMISSIONS

        public static final int REQUEST_CODE_PERMISSIONS
        See Also:
        Constant Field Values
      • CAMERA_PERMISSIONS

        public static final java.lang.String[] CAMERA_PERMISSIONS
    • Constructor Detail

      • CameraController

        public CameraController​(androidx.fragment.app.Fragment fragment,
                                androidx.camera.view.PreviewView previewView)
        Creates a basic CameraController that displays its preview to a view.
        Parameters:
        fragment - The fragment that uses the camera.
        previewView - The UI element in fragment to show camera preview on.
    • Method Detail

      • startCamera

        public void startCamera()
        Starts the camera and binds it's preview to the PreviewView UI element.
      • setupCamera

        protected abstract void setupCamera​(com.google.common.util.concurrent.ListenableFuture<androidx.camera.lifecycle.ProcessCameraProvider> cameraProviderFuture)
                                     throws java.util.concurrent.ExecutionException,
                                            java.lang.InterruptedException
        Adds in the camera's functionality
        Parameters:
        cameraProviderFuture - The camera's provider object
        Throws:
        java.util.concurrent.ExecutionException - if setup fails
        java.lang.InterruptedException - if setup fails
      • onDestroy

        public void onDestroy()
        Shut down the camera when it's no longer needed
      • cameraPermissionsGranted

        public boolean cameraPermissionsGranted()
        Checks if all required permissions are granted
        Returns:
        True if every permission under CameraController.REQUIRED_PERMISSIONS is granted