use of com.facebook.react.bridge.ReactMethod in project react-native-fbsdk by facebook.
the class FBShareDialogModule method canShow.
@ReactMethod
public void canShow(ReadableMap shareContent, Promise promise) {
if (getCurrentActivity() != null) {
ShareDialog shareDialog = new ShareDialog(getCurrentActivity());
promise.resolve(mShareDialogMode == null ? shareDialog.canShow(Utility.buildShareContent(shareContent)) : shareDialog.canShow(Utility.buildShareContent(shareContent), mShareDialogMode));
} else {
promise.reject("No current activity.");
}
}
use of com.facebook.react.bridge.ReactMethod in project react-native-fbsdk by facebook.
the class FBMessageDialogModule method canShow.
/**
* Indicates whether it is possible to show the dialog for ShareContent of the specified type.
* @param shareContentMap must be a valid {@link ShareContent}.
* @param promise Use promise to pass message dialog result to JS.
*/
@ReactMethod
public void canShow(ReadableMap shareContentMap, Promise promise) {
if (getCurrentActivity() != null) {
ShareContent shareContent = Utility.buildShareContent(shareContentMap);
MessageDialog messageDialog = new MessageDialog(getCurrentActivity());
promise.resolve(messageDialog.canShow(shareContent));
} else {
promise.reject("No current activity.");
}
}
use of com.facebook.react.bridge.ReactMethod in project react-native-camera by lwansbrough.
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);
}
}
}
}
use of com.facebook.react.bridge.ReactMethod in project react-native-image-picker by marcshilling.
the class ImagePickerModule method launchCamera.
// NOTE: Currently not reentrant / doesn't support concurrent requests
@ReactMethod
public void launchCamera(final ReadableMap options, final Callback callback) {
if (!isCameraAvailable()) {
responseHelper.invokeError(callback, "Camera not available");
return;
}
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_CAMERA)) {
return;
}
parseOptions(this.options);
int requestCode;
Intent cameraIntent;
if (pickVideo) {
requestCode = REQUEST_LAUNCH_VIDEO_CAPTURE;
cameraIntent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
cameraIntent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, videoQuality);
if (videoDurationLimit > 0) {
cameraIntent.putExtra(MediaStore.EXTRA_DURATION_LIMIT, videoDurationLimit);
}
} else {
requestCode = REQUEST_LAUNCH_IMAGE_CAPTURE;
cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
final File original = createNewFile(reactContext, this.options, false);
imageConfig = imageConfig.withOriginalFile(original);
if (imageConfig.original != null) {
cameraCaptureURI = RealPathUtil.compatUriFromFile(reactContext, imageConfig.original);
} else {
responseHelper.invokeError(callback, "Couldn't get file path for photo");
return;
}
if (cameraCaptureURI == null) {
responseHelper.invokeError(callback, "Couldn't get file path for photo");
return;
}
cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, cameraCaptureURI);
}
if (cameraIntent.resolveActivity(reactContext.getPackageManager()) == null) {
responseHelper.invokeError(callback, "Cannot launch camera");
return;
}
this.callback = callback;
// see https://code.google.com/p/android/issues/detail?id=76683
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.KITKAT) {
List<ResolveInfo> resInfoList = reactContext.getPackageManager().queryIntentActivities(cameraIntent, PackageManager.MATCH_DEFAULT_ONLY);
for (ResolveInfo resolveInfo : resInfoList) {
String packageName = resolveInfo.activityInfo.packageName;
reactContext.grantUriPermission(packageName, cameraCaptureURI, Intent.FLAG_GRANT_WRITE_URI_PERMISSION | Intent.FLAG_GRANT_READ_URI_PERMISSION);
}
}
try {
currentActivity.startActivityForResult(cameraIntent, requestCode);
} catch (ActivityNotFoundException e) {
e.printStackTrace();
responseHelper.invokeError(callback, "Cannot launch camera");
}
}
use of com.facebook.react.bridge.ReactMethod in project react-native-navigation by wix.
the class NavigationModule method setRoot.
@ReactMethod
public void setRoot(String commandId, ReadableMap rawLayoutTree, Promise promise) {
final LayoutNode layoutTree = LayoutNodeParser.parse(Objects.requireNonNull(jsonParser.parse(rawLayoutTree).optJSONObject("root")));
handle(() -> {
final ViewController<?> viewController = layoutFactory.create(layoutTree);
navigator().setRoot(viewController, new NativeCommandListener("setRoot", commandId, promise, eventEmitter, now), reactInstanceManager);
});
}
Aggregations