Refactor calls to UIManagerHelper.getUIManager

Summary:
This diff refactors the usages of UIManagerHelper.getUIManager() to make sure we always consider null objects.
Some of the callsites were throwing a NullPointerExcetpion, now they throw a more explicit exception.

changelog: [internal]

Reviewed By: makovkastar

Differential Revision: D19383064

fbshipit-source-id: 1806a37528e80cab1c8fdff5eb631aaf47bde819
This commit is contained in:
David Vacca authored and Facebook Github Bot committed 2020-01-22 17:50:13 -08:00
1 parent edcbfb9821
commit 39089b4c45
3 files changed
+33 -21

No files matched your search

@@ -680,22 +680,18 @@ public class UIManagerModule extends ReactContextBaseJavaModule
int reactTag, Dynamic commandId, @Nullable ReadableArray commandArgs) {
// TODO: this is a temporary approach to support ViewManagerCommands in Fabric until
// the dispatchViewManagerCommand() method is supported by Fabric JS API.
@Nullable
UIManager uiManager =
UIManagerHelper.getUIManager(
getReactApplicationContext(), ViewUtil.getUIManagerType(reactTag));
if (uiManager == null) {
return;
}
if (commandId.getType() == ReadableType.Number) {
final int commandIdNum = commandId.asInt();
UIManager uiManager =
UIManagerHelper.getUIManager(
getReactApplicationContext(), ViewUtil.getUIManagerType(reactTag));
if (uiManager != null) {
uiManager.dispatchCommand(reactTag, commandIdNum, commandArgs);
}
uiManager.dispatchCommand(reactTag, commandId.asInt(), commandArgs);
} else if (commandId.getType() == ReadableType.String) {
final String commandIdStr = commandId.asString();
UIManager uiManager =
UIManagerHelper.getUIManager(
getReactApplicationContext(), ViewUtil.getUIManagerType(reactTag));
if (uiManager != null) {
uiManager.dispatchCommand(reactTag, commandIdStr, commandArgs);
}
uiManager.dispatchCommand(reactTag, commandId.asString(), commandArgs);
}
}