From c4c74215fad0c7169c3001ec7ee76daa4e90daea Mon Sep 17 00:00:00 2001 From: Denis Koroskin Date: Mon, 30 Nov 2015 16:36:54 -0800 Subject: [PATCH] Allow extending UIViewOperationQueue Summary: public I need to extend NativeViewHierarchyManager to support a richer set of operations on Views, and those operations needs to be ran in UI thread. Existing UIViewOperationQueue doesn't know about those operations, so I need to extend it too to allow them. This patch is making the class constructor protected to allow subclassing it from another package. Should not have any functional changes. Reviewed By: astreet Differential Revision: D2554826 fb-gh-sync-id: ad2d44a61beb216d940e20cd1489d3b5da1b398b --- .../react/uimanager/UIViewOperationQueue.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIViewOperationQueue.java b/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIViewOperationQueue.java index ed507fd3e..f26a295ee 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIViewOperationQueue.java +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIViewOperationQueue.java @@ -46,7 +46,7 @@ public class UIViewOperationQueue { /** * A mutation or animation operation on the view hierarchy. */ - private interface UIOperation { + protected interface UIOperation { void execute(); } @@ -440,7 +440,7 @@ public class UIViewOperationQueue { private @Nullable NotThreadSafeViewHierarchyUpdateDebugListener mViewHierarchyUpdateDebugListener; - /* package */ UIViewOperationQueue( + protected UIViewOperationQueue( ReactApplicationContext reactContext, NativeViewHierarchyManager nativeViewHierarchyManager) { mNativeViewHierarchyManager = nativeViewHierarchyManager; @@ -484,6 +484,14 @@ public class UIViewOperationQueue { } } + /** + * Enqueues a UIOperation to be executed in UI thread. This method should only be used by a + * subclass to support UIOperations not provided by UIViewOperationQueue. + */ + protected void enqueueUIOperation(UIOperation operation) { + mOperations.add(operation); + } + public void enqueueRemoveRootView(int rootViewTag) { mOperations.add(new RemoveRootViewOperation(rootViewTag)); }