Append LayoutUpdateListener to UIViewOperationQueue
Summary: There are multiple UI thread passes during the layout process. The first is with all of the operations from React (createView, manageChildren, etc). The second is during onCollectExtraUpdates after the layout pass, when things like Text need to be precomputed before later being sent over to the views. The onLayoutUpdateListener needs to run AFTER onCollectExtraUpdates operations are executed, so this is now queued up in the UIViewOperationQueue Reviewed By: mdvacca Differential Revision: D9416260 fbshipit-source-id: d1a4eaf38a4f6c82d41def34ffb94d303e8f50d4
This commit is contained in:
parent
f7a11fcd97
commit
833954a669
|
@ -709,7 +709,7 @@ public class UIImplementation {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mLayoutUpdateListener != null) {
|
if (mLayoutUpdateListener != null) {
|
||||||
mLayoutUpdateListener.onLayoutUpdated(cssRoot);
|
mOperationsQueue.enqueueLayoutUpdateFinished(cssRoot, mLayoutUpdateListener);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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 class UIBlockOperation implements UIOperation {
|
||||||
private final UIBlock mBlock;
|
private final UIBlock mBlock;
|
||||||
public UIBlockOperation (UIBlock block) {
|
public UIBlockOperation (UIBlock block) {
|
||||||
|
@ -829,6 +845,10 @@ public class UIViewOperationQueue {
|
||||||
mOperations.add(new SendAccessibilityEvent(tag, eventType));
|
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) {
|
public void enqueueUIBlock(UIBlock block) {
|
||||||
mOperations.add(new UIBlockOperation(block));
|
mOperations.add(new UIBlockOperation(block));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue