Example usage for android.hardware.camera2 CameraMetadata LENS_STATE_MOVING

List of usage examples for android.hardware.camera2 CameraMetadata LENS_STATE_MOVING

Introduction

In this page you can find the example usage for android.hardware.camera2 CameraMetadata LENS_STATE_MOVING.

Prototype

int LENS_STATE_MOVING

To view the source code for android.hardware.camera2 CameraMetadata LENS_STATE_MOVING.

Click Source Link

Document

One or several of the lens parameters ( CaptureRequest#LENS_FOCAL_LENGTH android.lens.focalLength , CaptureRequest#LENS_FOCUS_DISTANCE android.lens.focusDistance , CaptureRequest#LENS_FILTER_DENSITY android.lens.filterDensity or CaptureRequest#LENS_APERTURE android.lens.aperture ) is currently changing.

Usage

From source file:com.android.camera.one.v2.OneCameraZslImpl.java

@Override
public void setFocusDistanceListener(FocusDistanceListener focusDistanceListener) {
    if (mFocusDistanceListener == null) {
        mCaptureManager.addMetadataChangeListener(CaptureResult.LENS_FOCUS_DISTANCE,
                new ImageCaptureManager.MetadataChangeListener() {
                    @Override//from ww w .  ja v a 2 s  .  co m
                    public void onImageMetadataChange(Key<?> key, Object oldValue, Object newValue,
                            CaptureResult result) {
                        Integer state = result.get(CaptureResult.LENS_STATE);

                        // Forward changes if we have a new value and the camera
                        // A) Doesn't support lens state or B) lens state is
                        // reported and it is reported as moving.
                        if (newValue != null && (state == null || state == CameraMetadata.LENS_STATE_MOVING)) {
                            mFocusDistanceListener.onFocusDistance((float) newValue, mLensRange);
                        }
                    }
                });
    }
    mFocusDistanceListener = focusDistanceListener;
}