Java Code Examples for com.facebook.react.common.MapBuilder#newHashMap()

The following examples show how to use com.facebook.react.common.MapBuilder#newHashMap() . 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: UIManagerModule.java    From react-native-GPay with MIT License 6 votes vote down vote up
@Deprecated
public UIManagerModule(
    ReactApplicationContext reactContext,
    List<ViewManager> viewManagersList,
    UIImplementationProvider uiImplementationProvider,
    int minTimeLeftInFrameForNonBatchedOperationMs) {
  super(reactContext);
  DisplayMetricsHolder.initDisplayMetricsIfNotInitialized(reactContext);
  mEventDispatcher = new EventDispatcher(reactContext);
  mCustomDirectEvents = MapBuilder.newHashMap();
  mModuleConstants = createConstants(viewManagersList, null, mCustomDirectEvents);
  mUIImplementation =
      uiImplementationProvider.createUIImplementation(
          reactContext,
          viewManagersList,
          mEventDispatcher,
          minTimeLeftInFrameForNonBatchedOperationMs);

  reactContext.addLifecycleEventListener(this);
}
 
Example 2
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 3
Source File: ToastModule.java    From react-native-GPay with MIT License 5 votes vote down vote up
@Override
public Map<String, Object> getConstants() {
  final Map<String, Object> constants = MapBuilder.newHashMap();
  constants.put(DURATION_SHORT_KEY, Toast.LENGTH_SHORT);
  constants.put(DURATION_LONG_KEY, Toast.LENGTH_LONG);
  constants.put(GRAVITY_TOP_KEY, Gravity.TOP | Gravity.CENTER_HORIZONTAL);
  constants.put(GRAVITY_BOTTOM_KEY, Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL);
  constants.put(GRAVITY_CENTER, Gravity.CENTER_HORIZONTAL | Gravity.CENTER_VERTICAL);
  return constants;
}
 
Example 4
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 5
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 6
Source File: ViewManagerRegistry.java    From react-native-GPay with MIT License 4 votes vote down vote up
public ViewManagerRegistry(UIManagerModule.ViewManagerResolver viewManagerResolver) {
  mViewManagers = MapBuilder.newHashMap();
  mViewManagerResolver = viewManagerResolver;
}
 
Example 7
Source File: ViewManagerRegistry.java    From react-native-GPay with MIT License 4 votes vote down vote up
public ViewManagerRegistry(Map<String, ViewManager> viewManagerMap) {
  mViewManagers =
      viewManagerMap != null ? viewManagerMap : MapBuilder.<String, ViewManager>newHashMap();
  mViewManagerResolver = null;
}
 
Example 8
Source File: UIManagerModuleConstantsHelper.java    From react-native-GPay with MIT License 4 votes vote down vote up
static Map<String, Object> createConstantsForViewManager(
    ViewManager viewManager,
    @Nullable Map defaultBubblingEvents,
    @Nullable Map defaultDirectEvents,
    @Nullable Map cumulativeBubblingEventTypes,
    @Nullable Map cumulativeDirectEventTypes) {
  Map<String, Object> viewManagerConstants = MapBuilder.newHashMap();

  Map viewManagerBubblingEvents = viewManager.getExportedCustomBubblingEventTypeConstants();
  if (viewManagerBubblingEvents != null) {
    recursiveMerge(cumulativeBubblingEventTypes, viewManagerBubblingEvents);
    recursiveMerge(viewManagerBubblingEvents, defaultBubblingEvents);
    viewManagerConstants.put(BUBBLING_EVENTS_KEY, viewManagerBubblingEvents);
  } else if (defaultBubblingEvents != null) {
    viewManagerConstants.put(BUBBLING_EVENTS_KEY, defaultBubblingEvents);
  }

  Map viewManagerDirectEvents = viewManager.getExportedCustomDirectEventTypeConstants();
  if (viewManagerDirectEvents != null) {
    recursiveMerge(cumulativeDirectEventTypes, viewManagerDirectEvents);
    recursiveMerge(viewManagerDirectEvents, defaultDirectEvents);
    viewManagerConstants.put(DIRECT_EVENTS_KEY, viewManagerDirectEvents);
  } else if (defaultDirectEvents != null) {
    viewManagerConstants.put(DIRECT_EVENTS_KEY, defaultDirectEvents);
  }

  Map customViewConstants = viewManager.getExportedViewConstants();
  if (customViewConstants != null) {
    viewManagerConstants.put("Constants", customViewConstants);
  }
  Map viewManagerCommands = viewManager.getCommandsMap();
  if (viewManagerCommands != null) {
    viewManagerConstants.put("Commands", viewManagerCommands);
  }
  Map<String, String> viewManagerNativeProps = viewManager.getNativeProps();
  if (!viewManagerNativeProps.isEmpty()) {
    viewManagerConstants.put("NativeProps", viewManagerNativeProps);
  }

  return viewManagerConstants;
}
 
Example 9
Source File: UIManagerModuleConstants.java    From react-native-GPay with MIT License 4 votes vote down vote up
public static Map<String, Object> getConstants() {
  Map<String, Object> constants = MapBuilder.newHashMap();
  constants.put(
      "UIView",
      MapBuilder.of(
          "ContentMode",
          MapBuilder.of(
              "ScaleAspectFit",
              ImageView.ScaleType.FIT_CENTER.ordinal(),
              "ScaleAspectFill",
              ImageView.ScaleType.CENTER_CROP.ordinal(),
              "ScaleAspectCenter",
              ImageView.ScaleType.CENTER_INSIDE.ordinal())));

  constants.put(
      "StyleConstants",
      MapBuilder.of(
          "PointerEventsValues",
          MapBuilder.of(
              "none",
              PointerEvents.NONE.ordinal(),
              "boxNone",
              PointerEvents.BOX_NONE.ordinal(),
              "boxOnly",
              PointerEvents.BOX_ONLY.ordinal(),
              "unspecified",
              PointerEvents.AUTO.ordinal())));

  constants.put(
      "PopupMenu",
      MapBuilder.of(
          ACTION_DISMISSED,
          ACTION_DISMISSED,
          ACTION_ITEM_SELECTED,
          ACTION_ITEM_SELECTED));

  constants.put(
    "AccessibilityEventTypes",
    MapBuilder.of(
        "typeWindowStateChanged",
        AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED,
        "typeViewFocused",
        AccessibilityEvent.TYPE_VIEW_FOCUSED,
        "typeViewClicked",
        AccessibilityEvent.TYPE_VIEW_CLICKED));

  return constants;
}