androidx.camera.core.CameraX Java Examples

The following examples show how to use androidx.camera.core.CameraX. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PublishFragment.java    From lbry-android with MIT License 6 votes vote down vote up
@SuppressLint("RestrictedApi")
public void onStop() {
    Context context = getContext();
    if (context instanceof MainActivity) {
        MainActivity activity = (MainActivity) context;
        activity.removeCameraPermissionListener(this);
        activity.removeStoragePermissionListener(this);
        activity.showFloatingWalletBalance();
        if (!MainActivity.startingFilePickerActivity) {
            activity.removeFilePickerListener(this);
        }
    }
    if (cameraPreviewInitialized) {
        CameraX.unbindAll();
    }
    super.onStop();
}
 
Example #2
Source File: MainActivity.java    From journaldev with MIT License 6 votes vote down vote up
private void showAcceptedRejectedButton(boolean acceptedRejected) {
    if (acceptedRejected) {
        CameraX.unbind(preview, imageAnalysis);
        llBottom.setVisibility(View.VISIBLE);
        btnCapture.hide();
        textureView.setVisibility(View.GONE);
    } else {
        btnCapture.show();
        llBottom.setVisibility(View.GONE);
        textureView.setVisibility(View.VISIBLE);
        textureView.post(new Runnable() {
            @Override
            public void run() {
                startCamera();
            }
        });
    }
}
 
Example #3
Source File: CameraXModule.java    From mollyim-android with GNU General Public License v3.0 5 votes vote down vote up
@RequiresPermission(permission.CAMERA)
public boolean hasCameraWithLensFacing(@CameraSelector.LensFacing int lensFacing) {
  String cameraId;
  try {
    cameraId = CameraX.getCameraWithLensFacing(lensFacing);
  } catch (Exception e) {
    throw new IllegalStateException("Unable to query lens facing.", e);
  }

  return cameraId != null;
}
 
Example #4
Source File: VideoCapture.java    From mollyim-android with GNU General Public License v3.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 *
 * @hide
 */
@Override
@Nullable
@RestrictTo(Scope.LIBRARY_GROUP)
protected UseCaseConfig.Builder<?, ?, ?> getDefaultBuilder(@Nullable CameraInfo cameraInfo) {
    VideoCaptureConfig defaults = CameraX.getDefaultUseCaseConfig(VideoCaptureConfig.class,
        cameraInfo);
    if (defaults != null) {
        return VideoCaptureConfig.Builder.fromConfig(defaults);
    }

    return null;
}
 
Example #5
Source File: PictureCustomCameraActivity.java    From PictureSelector with Apache License 2.0 5 votes vote down vote up
@SuppressLint("RestrictedApi")
@Override
protected void onDestroy() {
    if (mCameraView != null) {
        CameraX.unbindAll();
        mCameraView = null;
    }
    super.onDestroy();
}
 
Example #6
Source File: MainActivity.java    From journaldev with MIT License 5 votes vote down vote up
private void startCamera() {

        CameraX.unbindAll();
        preview = setPreview();
        imageCapture = setImageCapture();
        imageAnalysis = setImageAnalysis();

        //bind to lifecycle:
        CameraX.bindToLifecycle(this, preview, imageCapture, imageAnalysis);
    }