Search in sources :

Example 21 with ReadableMap

use of com.facebook.react.bridge.ReadableMap in project react-native-camera by lwansbrough.

the class FaceDetectorUtils method rotateFaceX.

public static WritableMap rotateFaceX(WritableMap face, int sourceWidth, double scaleX) {
    ReadableMap faceBounds = face.getMap("bounds");
    ReadableMap oldOrigin = faceBounds.getMap("origin");
    WritableMap mirroredOrigin = positionMirroredHorizontally(oldOrigin, sourceWidth, scaleX);
    double translateX = -faceBounds.getMap("size").getDouble("width");
    WritableMap translatedMirroredOrigin = positionTranslatedHorizontally(mirroredOrigin, translateX);
    WritableMap newBounds = Arguments.createMap();
    newBounds.merge(faceBounds);
    newBounds.putMap("origin", translatedMirroredOrigin);
    for (String landmarkName : landmarkNames) {
        ReadableMap landmark = face.hasKey(landmarkName) ? face.getMap(landmarkName) : null;
        if (landmark != null) {
            WritableMap mirroredPosition = positionMirroredHorizontally(landmark, sourceWidth, scaleX);
            face.putMap(landmarkName, mirroredPosition);
        }
    }
    face.putMap("bounds", newBounds);
    return face;
}
Also used : WritableMap(com.facebook.react.bridge.WritableMap) ReadableMap(com.facebook.react.bridge.ReadableMap)

Example 22 with ReadableMap

use of com.facebook.react.bridge.ReadableMap in project native-navigation by airbnb.

the class ReactToolbar method setRightButtons.

/* package */
void setRightButtons(Menu menu, ReadableArray buttons, final ReactInterface component) {
    mActionsHolder.clear();
    int length = buttons.size();
    for (int i = 0; i < length; i++) {
        ReadableMap button = buttons.getMap(i);
        String title = button.hasKey("title") && button.getType("title") == ReadableType.String ? button.getString("title") : String.format("Item %s", i);
        // use `length - i` for ordering so the button ordering is consistent with iOS
        MenuItem item = menu.add(Menu.NONE, Menu.NONE, length - i, title);
        if (button.hasKey("image")) {
            setMenuItemIcon(item, button.getMap("image"));
        }
        item.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
        final Object data = i;
        item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {

            @Override
            public boolean onMenuItemClick(MenuItem item) {
                component.emitEvent("onRightPress", data);
                return false;
            }
        });
    }
}
Also used : ReadableMap(com.facebook.react.bridge.ReadableMap) MenuItem(android.view.MenuItem)

Example 23 with ReadableMap

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

the class NavigationModuleTest method setRoot_delegatesToNavigator.

@Test
public void setRoot_delegatesToNavigator() throws JSONException {
    when(reactApplicationContext.getCurrentActivity()).thenReturn(activity);
    ReadableMap root = mock(ReadableMap.class);
    when(jsonParser.parse(root)).thenReturn(rootJson());
    ViewController rootViewController = mock(ViewController.class);
    when(layoutFactory.create(any(LayoutNode.class))).thenReturn(rootViewController);
    uut.setRoot("1", root, mock(Promise.class));
    ShadowLooper.idleMainLooper();
    verify(navigator).setRoot(eq(rootViewController), any(), any());
}
Also used : LayoutNode(com.reactnativenavigation.options.LayoutNode) Promise(com.facebook.react.bridge.Promise) ViewController(com.reactnativenavigation.viewcontrollers.viewcontroller.ViewController) ReadableMap(com.facebook.react.bridge.ReadableMap) BaseTest(com.reactnativenavigation.BaseTest) Test(org.junit.Test)

Aggregations

ReadableMap (com.facebook.react.bridge.ReadableMap)23 WritableMap (com.facebook.react.bridge.WritableMap)6 ReadableArray (com.facebook.react.bridge.ReadableArray)4 ReadableMapKeySetIterator (com.facebook.react.bridge.ReadableMapKeySetIterator)4 IOException (java.io.IOException)4 WritableArray (com.facebook.react.bridge.WritableArray)3 Resources (android.content.res.Resources)2 NonNull (android.support.annotation.NonNull)2 Nullable (android.support.annotation.Nullable)2 Promise (com.facebook.react.bridge.Promise)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 Activity (android.app.Activity)1 Notification (android.app.Notification)1 PendingIntent (android.app.PendingIntent)1 DialogInterface (android.content.DialogInterface)1 Intent (android.content.Intent)1 SharedPreferences (android.content.SharedPreferences)1 ApplicationInfo (android.content.pm.ApplicationInfo)1 Bitmap (android.graphics.Bitmap)1