Search in sources :

Example 86 with ReactMethod

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());
}
Also used : Camera(android.hardware.Camera) ReactMethod(com.facebook.react.bridge.ReactMethod)

Example 87 with ReactMethod

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);
            }
        }
    }
}
Also used : Camera(android.hardware.Camera) ReactMethod(com.facebook.react.bridge.ReactMethod)

Aggregations

ReactMethod (com.facebook.react.bridge.ReactMethod)87 Activity (android.app.Activity)21 WritableMap (com.facebook.react.bridge.WritableMap)17 Intent (android.content.Intent)10 Bundle (android.os.Bundle)10 ReactApplicationContext (com.facebook.react.bridge.ReactApplicationContext)6 WritableArray (com.facebook.react.bridge.WritableArray)5 ArrayList (java.util.ArrayList)5 Camera (android.hardware.Camera)4 InterstitialAd (com.facebook.ads.InterstitialAd)4 ShareContent (com.facebook.share.model.ShareContent)4 LayoutNode (com.reactnativenavigation.options.LayoutNode)4 LoginManager (com.facebook.login.LoginManager)3 ReactActivity (com.facebook.react.ReactActivity)3 LatLng (com.google.android.gms.maps.model.LatLng)3 NotificationManager (android.app.NotificationManager)2 ActivityNotFoundException (android.content.ActivityNotFoundException)2 RemoteException (android.os.RemoteException)2 NativeAdsManager (com.facebook.ads.NativeAdsManager)2 JSApplicationIllegalArgumentException (com.facebook.react.bridge.JSApplicationIllegalArgumentException)2