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 authored and Facebook Github Bot committed 2019-06-24 18:47:16 -07:00
1 parent 4b8d07ebf3
commit 3cae6fa950
11 files changed
+187 -17

No files matched your search

@@ -172,6 +172,18 @@ public abstract class ViewManager<T extends View, C extends ReactShadowNode>
public void receiveCommand(@Nonnull T root, int commandId, @Nullable ReadableArray args) {
}
/**
* Subclasses may use this method to receive events/commands directly from JS through the
* {@link UIManager}. Good example of such a command would be {@code scrollTo} request with
* coordinates for a {@link ScrollView} instance.
*
* @param root View instance that should receive the command
* @param commandId code of the command
* @param args optional arguments for the command
*/
public void receiveCommand(@Nonnull T root, String commandId, @Nullable ReadableArray args) {
}
/**
* Subclasses of {@link ViewManager} that expect to receive commands through
* {@link UIManagerModule#dispatchViewManagerCommand} should override this method returning the