use of com.facebook.react.bridge.ReactMethod in project react-native-camera by react-native-community.
the class RCTCameraModule method hasFlash.
@ReactMethod
public void hasFlash(ReadableMap options, final Promise promise) {
Camera camera = RCTCamera.getInstance().acquireCameraInstance(options.getInt("type"));
if (null == camera) {
promise.reject("No camera found.");
return;
}
List<String> flashModes = camera.getParameters().getSupportedFlashModes();
promise.resolve(null != flashModes && !flashModes.isEmpty());
}
use of com.facebook.react.bridge.ReactMethod in project react-native-camera by react-native-community.
the class RCTCameraModule method setZoom.
@ReactMethod
public void setZoom(ReadableMap options, int zoom) {
RCTCamera instance = RCTCamera.getInstance();
if (instance == null)
return;
Camera camera = instance.acquireCameraInstance(options.getInt("type"));
if (camera == null)
return;
Camera.Parameters parameters = camera.getParameters();
int maxZoom = parameters.getMaxZoom();
if (parameters.isZoomSupported()) {
if (zoom >= 0 && zoom < maxZoom) {
parameters.setZoom(zoom);
try {
camera.setParameters(parameters);
} catch (RuntimeException e) {
Log.e("RCTCameraModule", "setParameters failed", e);
}
}
}
}
Aggregations