RN Android: Support View Manager Commands that are strings

Summary:
Right now JS triggers a view manager command with the following code:

```
UIManager.dispatchViewManagerCommand(
  ReactNative.findNodeHandle(this),
  UIManager.getViewManagerConfig('RCTView').Commands.hotspotUpdate,
  [destX || 0, destY || 0],
);
```

As we want to get rid of calls to UIManager, we need to stop looking for the integer defined in native from JavaScript. We will be changing methods like this to be:

```
UIManager.dispatchViewManagerCommand(
  ReactNative.findNodeHandle(this),
  'hotspotUpdate',
  [destX || 0, destY || 0],
);
```

We need to support ints and Strings to be backwards compatible, but ints will be deprecated.

Reviewed By: shergin

Differential Revision: D15955444

fbshipit-source-id: d1c488975ae03404f8f851a7035b58a90ed34163
This commit is contained in:
Eli White
2019-06-24 18:47:16 -07:00
committed by Facebook Github Bot
parent 4b8d07ebf3
commit 3cae6fa950
11 changed files with 187 additions and 17 deletions
@@ -770,6 +770,21 @@ public class NativeViewHierarchyManager {
viewManager.receiveCommand(view, commandId, args);
}
public synchronized void dispatchCommand(
int reactTag,
String commandId,
@Nullable ReadableArray args) {
UiThreadUtil.assertOnUiThread();
View view = mTagsToViews.get(reactTag);
if (view == null) {
throw new IllegalViewOperationException("Trying to send command to a non-existing view " +
"with tag " + reactTag);
}
ViewManager viewManager = resolveViewManager(reactTag);
viewManager.receiveCommand(view, commandId, args);
}
/**
* Show a {@link PopupMenu}.
*