From f82a6d78c9acc10f46402492075fe6bd7f6f8095 Mon Sep 17 00:00:00 2001 From: David Vacca Date: Fri, 1 May 2020 00:17:38 -0700 Subject: [PATCH] Reduce exposure of UIManagerModule in the NativeAnimatedNodesManager class Summary: This diff reduces exposure of UIManagerModule in the NativeAnimatedNodesManager class, this is necessary to enable NativeDriverAnimations in Venice changelog: [Internal][Android] Internal change to enable native driver animations in RN bridgless mode Reviewed By: ejanzer Differential Revision: D21317629 fbshipit-source-id: 81cd4ade296de4757acefe566e1466154d6b4e4b --- .../react/animated/NativeAnimatedNodesManager.java | 12 ++++++++---- .../facebook/react/uimanager/UIManagerModule.java | 1 + 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/animated/NativeAnimatedNodesManager.java b/ReactAndroid/src/main/java/com/facebook/react/animated/NativeAnimatedNodesManager.java index 9ce9e66470c..2c99f40d655 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/animated/NativeAnimatedNodesManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/animated/NativeAnimatedNodesManager.java @@ -15,12 +15,14 @@ import com.facebook.react.bridge.Callback; import com.facebook.react.bridge.JSApplicationIllegalArgumentException; import com.facebook.react.bridge.ReadableArray; import com.facebook.react.bridge.ReadableMap; +import com.facebook.react.bridge.UIManager; import com.facebook.react.bridge.UiThreadUtil; import com.facebook.react.bridge.WritableMap; import com.facebook.react.common.ReactConstants; import com.facebook.react.uimanager.IllegalViewOperationException; import com.facebook.react.uimanager.UIManagerModule; import com.facebook.react.uimanager.events.Event; +import com.facebook.react.uimanager.events.EventDispatcher; import com.facebook.react.uimanager.events.EventDispatcherListener; import java.util.ArrayDeque; import java.util.ArrayList; @@ -53,14 +55,16 @@ import java.util.Queue; // there will be only one driver per mapping so all code code should be optimized around that. private final Map> mEventDrivers = new HashMap<>(); private final UIManagerModule.CustomEventNamesResolver mCustomEventNamesResolver; - private final UIManagerModule mUIManagerModule; + private final UIManager mUIManager; private int mAnimatedGraphBFSColor = 0; // Used to avoid allocating a new array on every frame in `runUpdates` and `onEventDispatch`. private final List mRunUpdateNodeList = new LinkedList<>(); public NativeAnimatedNodesManager(UIManagerModule uiManager) { - mUIManagerModule = uiManager; - uiManager.getEventDispatcher().addListener(this); + mUIManager = uiManager; + mUIManager.getEventDispatcher().addListener(this); + // TODO T64216139 Remove dependency of UIManagerModule when the Constants are not in Native + // anymore mCustomEventNamesResolver = uiManager.getDirectEventNamesResolver(); } @@ -85,7 +89,7 @@ import java.util.Queue; } else if ("value".equals(type)) { node = new ValueAnimatedNode(config); } else if ("props".equals(type)) { - node = new PropsAnimatedNode(config, this, mUIManagerModule); + node = new PropsAnimatedNode(config, this, mUIManager); } else if ("interpolation".equals(type)) { node = new InterpolationAnimatedNode(config); } else if ("addition".equals(type)) { diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModule.java b/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModule.java index 9d7879d425d..a6ce7ff7115 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModule.java +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModule.java @@ -807,6 +807,7 @@ public class UIManagerModule extends ReactContextBaseJavaModule mUIImplementation.setViewHierarchyUpdateDebugListener(listener); } + @Override public EventDispatcher getEventDispatcher() { return mEventDispatcher; }