Search in sources :

Example 46 with ReactMethod

use of com.facebook.react.bridge.ReactMethod in project react-native-fbsdk by facebook.

the class FBShareAPIModule method share.

/**
     * Share the content.
     * @param shareContentMap must be a valid {@link ShareContent}.
     * @param graphNode The graph node to share to (this can be a user id, event id, page id, group id, album
     * id, etc).
     * @param message The custom message that will accompany the share content.
     * @param promise Use promise to pass share api result to JS.
     */
@ReactMethod
public void share(ReadableMap shareContentMap, String graphNode, String message, Promise promise) {
    ShareContent shareContent = Utility.buildShareContent(shareContentMap);
    if (shareContent != null) {
        ShareApi shareApi = new ShareApi(shareContent);
        shareApi.setGraphNode(graphNode);
        shareApi.setMessage(message);
        shareApi.share(new ShareAPICallback(promise));
    } else {
        promise.reject("ShareContent cannot be null");
    }
}
Also used : ShareApi(com.facebook.share.ShareApi) ShareContent(com.facebook.share.model.ShareContent) ReactMethod(com.facebook.react.bridge.ReactMethod)

Example 47 with ReactMethod

use of com.facebook.react.bridge.ReactMethod in project react-native-fbsdk by facebook.

the class FBLoginManagerModule method logInWithReadPermissions.

/**
     * Attempts a Facebook login with the specified read permissions.
     * @param permissions must be one of the provided read permissions. See
     *                    <a href="https://developers.facebook.com/docs/facebook-login/permissions">
     *                    Facebook login permissions</a>.
     * @param promise Use promise to pass login result to JS after login finish.
     */
@ReactMethod
public void logInWithReadPermissions(ReadableArray permissions, final Promise promise) {
    final LoginManager loginManager = LoginManager.getInstance();
    loginManager.registerCallback(mCallbackManager, new LoginManagerCallback(promise));
    Activity activity = getCurrentActivity();
    if (activity != null) {
        loginManager.logInWithReadPermissions(activity, reactArrayToJavaStringCollection(permissions));
    }
}
Also used : LoginManager(com.facebook.login.LoginManager) Activity(android.app.Activity) ReactMethod(com.facebook.react.bridge.ReactMethod)

Example 48 with ReactMethod

use of com.facebook.react.bridge.ReactMethod in project react-native-image-picker by marcshilling.

the class ImagePickerModule method launchImageLibrary.

// NOTE: Currently not reentrant / doesn't support concurrent requests
@ReactMethod
public void launchImageLibrary(final ReadableMap options, final Callback callback) {
    final Activity currentActivity = getCurrentActivity();
    if (currentActivity == null) {
        responseHelper.invokeError(callback, "can't find current Activity");
        return;
    }
    this.options = options;
    if (!permissionsCheck(currentActivity, callback, REQUEST_PERMISSIONS_FOR_LIBRARY)) {
        return;
    }
    parseOptions(this.options);
    int requestCode;
    Intent libraryIntent;
    if (pickVideo) {
        requestCode = REQUEST_LAUNCH_VIDEO_LIBRARY;
        libraryIntent = new Intent(Intent.ACTION_PICK);
        libraryIntent.setType("video/*");
    } else {
        requestCode = REQUEST_LAUNCH_IMAGE_LIBRARY;
        libraryIntent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
    }
    if (libraryIntent.resolveActivity(reactContext.getPackageManager()) == null) {
        responseHelper.invokeError(callback, "Cannot launch photo library");
        return;
    }
    this.callback = callback;
    try {
        currentActivity.startActivityForResult(libraryIntent, requestCode);
    } catch (ActivityNotFoundException e) {
        e.printStackTrace();
        responseHelper.invokeError(callback, "Cannot launch photo library");
    }
}
Also used : ActivityNotFoundException(android.content.ActivityNotFoundException) ReactActivity(com.facebook.react.ReactActivity) Activity(android.app.Activity) Intent(android.content.Intent) ReactMethod(com.facebook.react.bridge.ReactMethod)

Example 49 with ReactMethod

use of com.facebook.react.bridge.ReactMethod in project react-native-navigation by wix.

the class NavigationReactModule method showLightBox.

@ReactMethod
public void showLightBox(final ReadableMap params) {
    LightBoxParams lbp = new LightBoxParamsParser(BundleConverter.toBundle(params)).parse();
    NavigationCommandsHandler.showLightBox(lbp);
}
Also used : LightBoxParamsParser(com.reactnativenavigation.params.parsers.LightBoxParamsParser) LightBoxParams(com.reactnativenavigation.params.LightBoxParams) ReactMethod(com.facebook.react.bridge.ReactMethod)

Example 50 with ReactMethod

use of com.facebook.react.bridge.ReactMethod in project react-native-gesture-handler by kmagiera.

the class RNGestureHandlerModule method updateGestureHandler.

@ReactMethod
public void updateGestureHandler(int handlerTag, ReadableMap config) {
    GestureHandler handler = mRegistry.getHandler(handlerTag);
    if (handler != null) {
        HandlerFactory factory = findFactoryForHandler(handler);
        if (factory != null) {
            mInteractionManager.dropRelationsForHandlerWithTag(handlerTag);
            mInteractionManager.configureInteractions(handler, config);
            factory.configure(handler, config);
        }
    }
}
Also used : TapGestureHandler(com.swmansion.gesturehandler.TapGestureHandler) GestureHandler(com.swmansion.gesturehandler.GestureHandler) PinchGestureHandler(com.swmansion.gesturehandler.PinchGestureHandler) PanGestureHandler(com.swmansion.gesturehandler.PanGestureHandler) RotationGestureHandler(com.swmansion.gesturehandler.RotationGestureHandler) LongPressGestureHandler(com.swmansion.gesturehandler.LongPressGestureHandler) NativeViewGestureHandler(com.swmansion.gesturehandler.NativeViewGestureHandler) 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