diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIImplementation.java b/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIImplementation.java index 2baee93ce..e24718670 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIImplementation.java +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIImplementation.java @@ -709,7 +709,7 @@ public class UIImplementation { } if (mLayoutUpdateListener != null) { - mLayoutUpdateListener.onLayoutUpdated(cssRoot); + mOperationsQueue.enqueueLayoutUpdateFinished(cssRoot, mLayoutUpdateListener); } } } 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 783110b96..772286cd6 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIViewOperationQueue.java +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIViewOperationQueue.java @@ -556,6 +556,22 @@ public class UIViewOperationQueue { } } + private final class LayoutUpdateFinishedOperation implements UIOperation { + + private final ReactShadowNode mNode; + private final UIImplementation.LayoutUpdateListener mListener; + + private LayoutUpdateFinishedOperation(ReactShadowNode node, UIImplementation.LayoutUpdateListener listener) { + mNode = node; + mListener = listener; + } + + @Override + public void execute() { + mListener.onLayoutUpdated(mNode); + } + } + private class UIBlockOperation implements UIOperation { private final UIBlock mBlock; public UIBlockOperation (UIBlock block) { @@ -829,6 +845,10 @@ public class UIViewOperationQueue { mOperations.add(new SendAccessibilityEvent(tag, eventType)); } + public void enqueueLayoutUpdateFinished(ReactShadowNode node, UIImplementation.LayoutUpdateListener listener) { + mOperations.add(new LayoutUpdateFinishedOperation(node, listener)); + } + public void enqueueUIBlock(UIBlock block) { mOperations.add(new UIBlockOperation(block)); }