From ab5de9b9ae51fd346e01e3b267af12feeea706d5 Mon Sep 17 00:00:00 2001 From: Felix Oghina Date: Tue, 4 Oct 2016 12:21:03 -0700 Subject: [PATCH] pass EventDispatcher to UIImplementation constructor Summary: This way `UIImplementation` can hold on to it and use it outside of calls from the `UIManagerModule`. @public Reviewed By: lexs Differential Revision: D3899774 --- .../react/flat/FlatUIImplementation.java | 22 ++++++++++--------- .../flat/FlatUIImplementationProvider.java | 6 +++-- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/flat/FlatUIImplementation.java b/ReactAndroid/src/main/java/com/facebook/react/flat/FlatUIImplementation.java index dffe1f4a9..753cb88b9 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/flat/FlatUIImplementation.java +++ b/ReactAndroid/src/main/java/com/facebook/react/flat/FlatUIImplementation.java @@ -21,8 +21,8 @@ import com.facebook.react.bridge.Callback; import com.facebook.react.bridge.ReactApplicationContext; import com.facebook.react.bridge.ReadableArray; import com.facebook.react.modules.i18nmanager.I18nUtil; -import com.facebook.react.uimanager.ReactStylesDiffMap; import com.facebook.react.uimanager.ReactShadowNode; +import com.facebook.react.uimanager.ReactStylesDiffMap; import com.facebook.react.uimanager.UIImplementation; import com.facebook.react.uimanager.ViewManager; import com.facebook.react.uimanager.ViewManagerRegistry; @@ -38,7 +38,8 @@ public class FlatUIImplementation extends UIImplementation { public static FlatUIImplementation createInstance( ReactApplicationContext reactContext, - List viewManagers) { + List viewManagers, + EventDispatcher eventDispatcher) { ReactImageManager reactImageManager = findReactImageManager(viewManagers); if (reactImageManager != null) { @@ -73,7 +74,8 @@ public class FlatUIImplementation extends UIImplementation { reactContext, reactImageManager, viewManagerRegistry, - operationsQueue + operationsQueue, + eventDispatcher ); } @@ -90,8 +92,9 @@ public class FlatUIImplementation extends UIImplementation { ReactApplicationContext reactContext, @Nullable ReactImageManager reactImageManager, ViewManagerRegistry viewManagers, - FlatUIViewOperationQueue operationsQueue) { - super(reactContext, viewManagers, operationsQueue); + FlatUIViewOperationQueue operationsQueue, + EventDispatcher eventDispatcher) { + super(reactContext, viewManagers, operationsQueue, eventDispatcher); mReactContext = reactContext; mStateBuilder = new StateBuilder(operationsQueue); mReactImageManager = reactImageManager; @@ -502,17 +505,16 @@ public class FlatUIImplementation extends UIImplementation { } @Override - protected void updateViewHierarchy(EventDispatcher eventDispatcher) { - super.updateViewHierarchy(eventDispatcher); - mStateBuilder.afterUpdateViewHierarchy(eventDispatcher); + protected void updateViewHierarchy() { + super.updateViewHierarchy(); + mStateBuilder.afterUpdateViewHierarchy(mEventDispatcher); } @Override protected void applyUpdatesRecursive( ReactShadowNode cssNode, float absoluteX, - float absoluteY, - EventDispatcher eventDispatcher) { + float absoluteY) { mStateBuilder.applyUpdates((FlatRootShadowNode) cssNode); } diff --git a/ReactAndroid/src/main/java/com/facebook/react/flat/FlatUIImplementationProvider.java b/ReactAndroid/src/main/java/com/facebook/react/flat/FlatUIImplementationProvider.java index e9ca47a78..d3921faed 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/flat/FlatUIImplementationProvider.java +++ b/ReactAndroid/src/main/java/com/facebook/react/flat/FlatUIImplementationProvider.java @@ -14,6 +14,7 @@ import java.util.List; import com.facebook.react.bridge.ReactApplicationContext; import com.facebook.react.uimanager.UIImplementationProvider; import com.facebook.react.uimanager.ViewManager; +import com.facebook.react.uimanager.events.EventDispatcher; /** * UIImplementationProvider that creates instances of {@link FlatUIImplementation}. @@ -22,7 +23,8 @@ public final class FlatUIImplementationProvider extends UIImplementationProvider @Override public FlatUIImplementation createUIImplementation( ReactApplicationContext reactContext, - List viewManagers) { - return FlatUIImplementation.createInstance(reactContext, viewManagers); + List viewManagers, + EventDispatcher eventDispatcher) { + return FlatUIImplementation.createInstance(reactContext, viewManagers, eventDispatcher); } }