Backed out changeset 322626be193e

Reviewed By: wutalman

Differential Revision: D6258856

fbshipit-source-id: 392dc91f87148c70817f13858a7fcd368f028b2d
This commit is contained in:
Omri Gindi
2017-11-07 04:34:41 -08:00
committed by Facebook Github Bot
parent 164591218f
commit a6465d1c17
3 changed files with 55 additions and 28 deletions

View File

@@ -24,9 +24,6 @@ import javax.annotation.Nullable;
*/
/* package */ class UIManagerModuleConstantsHelper {
private static final String BUBBLING_EVENTS_KEY = "bubblingEventTypes";
private static final String DIRECT_EVENTS_KEY = "directEventTypes";
/**
* Generates a lazy discovery enabled version of {@link UIManagerModule} constants. It only
* contains a list of view manager names, so that JS side is aware of the managers there are.
@@ -41,12 +38,6 @@ import javax.annotation.Nullable;
return constants;
}
/* package */ static Map<String, Object> getDefaultExportableEventTypes() {
return MapBuilder.<String, Object>of(
BUBBLING_EVENTS_KEY, UIManagerModuleConstants.getBubblingEventTypeConstants(),
DIRECT_EVENTS_KEY, UIManagerModuleConstants.getDirectEventTypeConstants());
}
/**
* Generates map of constants that is then exposed by {@link UIManagerModule}.
* Provided list of {@param viewManagers} is then used to populate content of
@@ -93,6 +84,8 @@ import javax.annotation.Nullable;
try {
Map viewManagerConstants = createConstantsForViewManager(
viewManager,
null,
null,
allBubblingEventTypes,
allDirectEventTypes);
if (!viewManagerConstants.isEmpty()) {
@@ -110,20 +103,31 @@ import javax.annotation.Nullable;
/* package */ static Map<String, Object> createConstantsForViewManager(
ViewManager viewManager,
@Nullable Map defaultBubblingEvents,
@Nullable Map defaultDirectEvents,
@Nullable Map cumulativeBubblingEventTypes,
@Nullable Map cumulativeDirectEventTypes) {
final String BUBBLING_EVENTS_KEY = "bubblingEventTypes";
final String DIRECT_EVENTS_KEY = "directEventTypes";
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();