com.facebook.react.common.MapBuilder Java Examples

The following examples show how to use com.facebook.react.common.MapBuilder. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RNArcGISMapViewManager.java    From react-native-arcgis-mapview with MIT License 6 votes vote down vote up
@Override
public Map<String, Integer> getCommandsMap() {
    Map<String, Integer> map = MapBuilder.of(
            "showCalloutViaManager",SHOW_CALLOUT,
            "centerMapViaManager", CENTER_MAP,
            "addGraphicsOverlayViaManager", ADD_GRAPHICS_OVERLAY,
            "removeGraphicsOverlayViaManager",REMOVE_GRAPHICS_OVERLAY,
            "addPointsToOverlayViaManager",ADD_POINTS_TO_OVERLAY,
            "removePointsFromOverlayViaManager", REMOVE_POINTS_FROM_OVERLAY,
            "updatePointsInGraphicsOverlayViaManager", UPDATE_POINTS_IN_GRAPHICS_OVERLAY
    );
    // Ran out of space in the constructor lol
    map.put("routeGraphicsOverlayViaManager",ROUTE_GRAPHICS_OVERLAY);
    map.put("setRouteIsVisible", SET_ROUTE_IS_VISIBLE);
    map.put("dispose", DISPOSE);
    return map;
}
 
Example #2
Source File: AMapMarkerManager.java    From react-native-amap with MIT License 6 votes vote down vote up
@Override
@Nullable
public Map getExportedCustomDirectEventTypeConstants() {
    Map<String, Map<String, String>> map = MapBuilder.of(
            "onPress", MapBuilder.of("registrationName", "onPress"),
            "onCalloutPress", MapBuilder.of("registrationName", "onCalloutPress"),
            "onDragStart", MapBuilder.of("registrationName", "onDragStart"),
            "onDrag", MapBuilder.of("registrationName", "onDrag"),
            "onDragEnd", MapBuilder.of("registrationName", "onDragEnd")
    );

    map.putAll(MapBuilder.of(
            "onDragStart", MapBuilder.of("registrationName", "onDragStart"),
            "onDrag", MapBuilder.of("registrationName", "onDrag"),
            "onDragEnd", MapBuilder.of("registrationName", "onDragEnd")
    ));

    return map;
}
 
Example #3
Source File: CustomTwilioVideoViewManager.java    From react-native-twilio-video-webrtc with MIT License 6 votes vote down vote up
@Override
@Nullable
public Map<String, Integer> getCommandsMap() {
    return MapBuilder.<String, Integer>builder()
            .put("connectToRoom", CONNECT_TO_ROOM)
            .put("disconnect", DISCONNECT)
            .put("switchCamera", SWITCH_CAMERA)
            .put("toggleVideo", TOGGLE_VIDEO)
            .put("toggleSound", TOGGLE_SOUND)
            .put("getStats", GET_STATS)
            .put("disableOpenSLES", DISABLE_OPENSL_ES)
            .put("toggleRemoteSound", TOGGLE_REMOTE_SOUND)
            .put("toggleBluetoothHeadset", TOGGLE_BLUETOOTH_HEADSET)
            .put("sendString", SEND_STRING)
            .build();
}
 
Example #4
Source File: ViewManagerRegistry.java    From react-native-GPay with MIT License 5 votes vote down vote up
public ViewManagerRegistry(List<ViewManager> viewManagerList) {
  Map<String, ViewManager> viewManagerMap = MapBuilder.newHashMap();
  for (ViewManager viewManager : viewManagerList) {
    viewManagerMap.put(viewManager.getName(), viewManager);
  }

  mViewManagers = viewManagerMap;
  mViewManagerResolver = null;
}
 
Example #5
Source File: UIManagerModuleConstantsTest.java    From react-native-GPay with MIT License 5 votes vote down vote up
@Test
public void testCustomViewConstants() {
  ViewManager mockViewManager = mock(ViewManager.class);
  List<ViewManager> viewManagers = Arrays.asList(mockViewManager);
  when(mockViewManager.getName()).thenReturn("RedPandaPhotoOfTheDayView");
  when(mockViewManager.getExportedViewConstants())
      .thenReturn(MapBuilder.of("PhotoSizeType", MapBuilder.of("Small", 1, "Large", 2)));
  UIManagerModule uiManagerModule =
      new UIManagerModule(mReactContext, viewManagers, 0);
  Map<String, Object> constants = uiManagerModule.getConstants();
  assertThat(constants).containsKey("RedPandaPhotoOfTheDayView");
  assertThat((Map) constants.get("RedPandaPhotoOfTheDayView")).containsKey("Constants");
  assertThat((Map) valueAtPath(constants, "RedPandaPhotoOfTheDayView", "Constants"))
      .containsKey("PhotoSizeType");
}
 
Example #6
Source File: ReactViewPagerManager.java    From react-native-image-zoom with MIT License 5 votes vote down vote up
@Override
public Map<String,Integer> getCommandsMap() {
    return MapBuilder.of(
            "setPage",
            COMMAND_SET_PAGE,
            "setPageWithoutAnimation",
            COMMAND_SET_PAGE_WITHOUT_ANIMATION);
}
 
Example #7
Source File: ScreenViewManager.java    From react-native-screens with MIT License 5 votes vote down vote up
@Nullable
@Override
public Map getExportedCustomDirectEventTypeConstants() {
  return MapBuilder.of(
          ScreenDismissedEvent.EVENT_NAME,
          MapBuilder.of("registrationName", "onDismissed"),
          ScreenAppearEvent.EVENT_NAME,
          MapBuilder.of("registrationName", "onAppear"),
          StackFinishTransitioningEvent.EVENT_NAME,
          MapBuilder.of("registrationName", "onFinishTransitioning"));
}
 
Example #8
Source File: AMapMarkerManager.java    From react-native-amap with MIT License 5 votes vote down vote up
@Override
@Nullable
public Map<String, Integer> getCommandsMap() {
    return MapBuilder.of(
            "showCallout", SHOW_INFO_WINDOW,
            "hideCallout", HIDE_INFO_WINDOW
    );
}
 
Example #9
Source File: NSTStreetViewManager.java    From react-native-streetview with MIT License 5 votes vote down vote up
@Override
public @Nullable
Map getExportedCustomDirectEventTypeConstants() {
    return MapBuilder.of(
            NSTStreetViewEvent.eventNameForType(NSTStreetViewEvent.ON_ERROR), MapBuilder.of("registrationName", NSTStreetViewEvent.eventNameForType(NSTStreetViewEvent.ON_ERROR)),
            NSTStreetViewEvent.eventNameForType(NSTStreetViewEvent.ON_SUCCESS), MapBuilder.of("registrationName", NSTStreetViewEvent.eventNameForType(NSTStreetViewEvent.ON_SUCCESS))
    );
}
 
Example #10
Source File: AppBarLayoutManager.java    From react-native-collapsing-toolbar with MIT License 5 votes vote down vote up
@Nullable
@Override
public Map<String, Object> getExportedCustomBubblingEventTypeConstants() {
    return MapBuilder.<String, Object>builder()
        .put("topOffsetChanged",
            MapBuilder.of(
                "phasedRegistrationNames",
                MapBuilder.of(
                    "bubbled", "onOffsetChanged", "captured", "onOffsetChangedCapture")))
        .build();
}
 
Example #11
Source File: AppBarLayoutManager.java    From react-native-collapsing-toolbar with MIT License 5 votes vote down vote up
@Override
public @javax.annotation.Nullable
Map<String, Integer> getCommandsMap() {
    return MapBuilder.of(
            "show", COMMAND_SHOW,
            "hide", COMMAND_HIDE,
            "redraw", COMMAND_REDRAW
    );
}
 
Example #12
Source File: RNTurbolinksModule.java    From react-native-turbolinks with MIT License 5 votes vote down vote up
@Override
public Map<String, Object> getConstants() {
    return MapBuilder.<String, Object>of(
            "ErrorCode", MapBuilder.<String, Object>of("httpFailure", 0, "networkFailure", 1),
            "Action", MapBuilder.<String, Object>of("advance", "advance", "replace", "replace", "restore", "restore")
    );
}
 
Example #13
Source File: MerryPhotoViewManager.java    From photo-viewer with Apache License 2.0 5 votes vote down vote up
@Nullable
@Override
public Map<String, Object> getExportedCustomDirectEventTypeConstants() {
    return MapBuilder.<String, Object>builder()
            .put("onChange", MapBuilder.of("registrationName", "onChange"))
            .put("onDismiss", MapBuilder.of("registrationName", "onDismiss")).build();
}
 
Example #14
Source File: TapjoyModule.java    From react-native-tapjoy with MIT License 5 votes vote down vote up
@Nullable
@Override
public Map<String, Object> getConstants() {
    MapBuilder.Builder<String, Object> builder = MapBuilder.builder();
    List<String> events = new ArrayList<>();

    for (Object event : Events.values()) {
        events.add(event.toString());
    }

    builder.put("events", events);
    return builder.build();
}
 
Example #15
Source File: AMapPolylineManager.java    From react-native-amap with MIT License 5 votes vote down vote up
@Override
@Nullable
public Map getExportedCustomDirectEventTypeConstants() {
  return MapBuilder.of(
      "onPress", MapBuilder.of("registrationName", "onPress")
  );
}
 
Example #16
Source File: MagnetWebViewManager.java    From magnet-client with Mozilla Public License 2.0 5 votes vote down vote up
@Override
public @Nullable Map getExportedCustomDirectEventTypeConstants() {
    return MapBuilder.of(
            "magnetWebViewLoaded",
            MapBuilder.of("registrationName", "onMagnetWebViewLoaded")
    );
}
 
Example #17
Source File: ReactExoplayerViewManager.java    From react-native-video with MIT License 5 votes vote down vote up
@Override
public @Nullable Map<String, Object> getExportedViewConstants() {
    return MapBuilder.<String, Object>of(
            "ScaleNone", Integer.toString(ResizeMode.RESIZE_MODE_FIT),
            "ScaleAspectFit", Integer.toString(ResizeMode.RESIZE_MODE_FIT),
            "ScaleToFill", Integer.toString(ResizeMode.RESIZE_MODE_FILL),
            "ScaleAspectFill", Integer.toString(ResizeMode.RESIZE_MODE_CENTER_CROP)
    );
}
 
Example #18
Source File: FloatingActionButtonManager.java    From react-native-bottom-sheet-behavior with MIT License 5 votes vote down vote up
@Override
public Map<String,Integer> getCommandsMap() {
    return MapBuilder.of(
            "setAnchorId", COMMAND_SET_ANCHOR_ID,
            "show", COMMAND_SHOW,
            "hide", COMMAND_HIDE
    );
}
 
Example #19
Source File: RedBoxDialog.java    From react-native-GPay with MIT License 5 votes vote down vote up
private static JSONObject stackFrameToJson(StackFrame frame) {
  return new JSONObject(
      MapBuilder.of(
          "file", frame.getFile(),
          "methodName", frame.getMethod(),
          "lineNumber", frame.getLine(),
          "column", frame.getColumn()
      ));
}
 
Example #20
Source File: StackTraceHelper.java    From react-native-GPay with MIT License 5 votes vote down vote up
/**
 * Convert the stack frame to a JSON representation.
 */
public JSONObject toJSON() {
  return new JSONObject(
      MapBuilder.of(
          "file", getFile(),
          "methodName", getMethod(),
          "lineNumber", getLine(),
          "column", getColumn()));
}
 
Example #21
Source File: ReactQueueConfigurationImpl.java    From react-native-GPay with MIT License 5 votes vote down vote up
public static ReactQueueConfigurationImpl create(
    ReactQueueConfigurationSpec spec,
    QueueThreadExceptionHandler exceptionHandler) {
  Map<MessageQueueThreadSpec, MessageQueueThreadImpl> specsToThreads = MapBuilder.newHashMap();

  MessageQueueThreadSpec uiThreadSpec = MessageQueueThreadSpec.mainThreadSpec();
  MessageQueueThreadImpl uiThread =
    MessageQueueThreadImpl.create(uiThreadSpec, exceptionHandler);
  specsToThreads.put(uiThreadSpec, uiThread);

  MessageQueueThreadImpl jsThread = specsToThreads.get(spec.getJSQueueThreadSpec());
  if (jsThread == null) {
    jsThread = MessageQueueThreadImpl.create(spec.getJSQueueThreadSpec(), exceptionHandler);
  }

  MessageQueueThreadImpl nativeModulesThread =
      specsToThreads.get(spec.getNativeModulesQueueThreadSpec());
  if (nativeModulesThread == null) {
    nativeModulesThread =
        MessageQueueThreadImpl.create(spec.getNativeModulesQueueThreadSpec(), exceptionHandler);
  }

  return new ReactQueueConfigurationImpl(
    uiThread,
    nativeModulesThread,
    jsThread);
}
 
Example #22
Source File: BannerViewManager.java    From react-native-fbads with MIT License 5 votes vote down vote up
@Override
public @Nullable Map getExportedCustomDirectEventTypeConstants() {
  return MapBuilder.of(
    "onAdPress",
    MapBuilder.of("registrationName", "onAdPress"),
    "onAdError",
    MapBuilder.of("registrationName", "onAdError"),
    "onLoggingImpression",
    MapBuilder.of("registrationName", "onLoggingImpression"),
    "onAdLoad",
    MapBuilder.of("registrationName", "onAdLoad")
  );
}
 
Example #23
Source File: BlobModule.java    From react-native-GPay with MIT License 5 votes vote down vote up
@Override
public @Nullable Map<String, Object> getConstants() {
  // The application can register BlobProvider as a ContentProvider so that blobs are resolvable.
  // If it does, it needs to tell us what authority was used via this string resource.
  Resources resources = getReactApplicationContext().getResources();
  String packageName = getReactApplicationContext().getPackageName();
  int resourceId = resources.getIdentifier("blob_provider_authority", "string", packageName);
  if (resourceId == 0) {
    return null;
  }

  return MapBuilder.<String, Object>of(
    "BLOB_URI_SCHEME", "content", "BLOB_URI_HOST", resources.getString(resourceId));
}
 
Example #24
Source File: I18nManagerModule.java    From react-native-GPay with MIT License 5 votes vote down vote up
@Override
public Map<String, Object> getConstants() {
  final Context context = getContext();
  final Locale locale = context.getResources().getConfiguration().locale;

  final Map<String, Object> constants = MapBuilder.newHashMap();
  constants.put("isRTL", sharedI18nUtilInstance.isRTL(context));
  constants.put(
      "doLeftAndRightSwapInRTL", sharedI18nUtilInstance.doLeftAndRightSwapInRTL(context));
  constants.put("localeIdentifier", locale.toString());
  return constants;
}
 
Example #25
Source File: ReactImageManager.java    From react-native-GPay with MIT License 5 votes vote down vote up
@Override
public @Nullable Map getExportedCustomDirectEventTypeConstants() {
  return MapBuilder.of(
    ImageLoadEvent.eventNameForType(ImageLoadEvent.ON_LOAD_START),
      MapBuilder.of("registrationName", "onLoadStart"),
    ImageLoadEvent.eventNameForType(ImageLoadEvent.ON_LOAD),
      MapBuilder.of("registrationName", "onLoad"),
    ImageLoadEvent.eventNameForType(ImageLoadEvent.ON_ERROR),
      MapBuilder.of("registrationName", "onError"),
    ImageLoadEvent.eventNameForType(ImageLoadEvent.ON_LOAD_END),
      MapBuilder.of("registrationName", "onLoadEnd"));
}
 
Example #26
Source File: ReactScrollViewManager.java    From react-native-GPay with MIT License 5 votes vote down vote up
public static Map<String, Object> createExportedCustomDirectEventTypeConstants() {
  return MapBuilder.<String, Object>builder()
      .put(ScrollEventType.getJSEventName(ScrollEventType.SCROLL), MapBuilder.of("registrationName", "onScroll"))
      .put(ScrollEventType.getJSEventName(ScrollEventType.BEGIN_DRAG), MapBuilder.of("registrationName", "onScrollBeginDrag"))
      .put(ScrollEventType.getJSEventName(ScrollEventType.END_DRAG), MapBuilder.of("registrationName", "onScrollEndDrag"))
      .put(ScrollEventType.getJSEventName(ScrollEventType.MOMENTUM_BEGIN), MapBuilder.of("registrationName", "onMomentumScrollBegin"))
      .put(ScrollEventType.getJSEventName(ScrollEventType.MOMENTUM_END), MapBuilder.of("registrationName", "onMomentumScrollEnd"))
      .build();
}
 
Example #27
Source File: ReactScrollViewCommandHelper.java    From react-native-GPay with MIT License 5 votes vote down vote up
public static Map<String,Integer> getCommandsMap() {
  return MapBuilder.of(
      "scrollTo",
      COMMAND_SCROLL_TO,
      "scrollToEnd",
      COMMAND_SCROLL_TO_END,
      "flashScrollIndicators",
      COMMAND_FLASH_SCROLL_INDICATORS);
}
 
Example #28
Source File: ReactToolbarManager.java    From react-native-GPay with MIT License 5 votes vote down vote up
@Nullable
@Override
public Map<String, Object> getExportedViewConstants() {
  return MapBuilder.<String, Object>of(
      "ShowAsAction",
      MapBuilder.of(
          "never", MenuItem.SHOW_AS_ACTION_NEVER,
          "always", MenuItem.SHOW_AS_ACTION_ALWAYS,
          "ifRoom", MenuItem.SHOW_AS_ACTION_IF_ROOM));
}
 
Example #29
Source File: ReactViewPagerManager.java    From react-native-GPay with MIT License 5 votes vote down vote up
@Override
public Map getExportedCustomDirectEventTypeConstants() {
  return MapBuilder.of(
      PageScrollEvent.EVENT_NAME, MapBuilder.of("registrationName", "onPageScroll"),
      PageScrollStateChangedEvent.EVENT_NAME, MapBuilder.of("registrationName", "onPageScrollStateChanged"),
      PageSelectedEvent.EVENT_NAME, MapBuilder.of("registrationName", "onPageSelected"));
}
 
Example #30
Source File: TabLayoutManager.java    From react-native-android-kit with MIT License 5 votes vote down vote up
@Nullable
@Override
public Map<String, Integer> getCommandsMap() {
	return MapBuilder.of(
			"setupWithViewPager",
			COMMAND_SETUPWITHVIEWPAGER
	);
}