Permalink
Browse files

Add callback for UIImplementation layout updates

Differential Revision: D6063839

fbshipit-source-id: ae08fd2fc6c6365813b8077efe14990a0355a5c7
  • Loading branch information...
ayc1 authored and facebook-github-bot committed Oct 17, 2017
1 parent 47bfbbb commit 91372e8f9aafcad2b5594175b1a3ce6f9c8f3b8e
Showing with 20 additions and 0 deletions.
  1. +20 −0 ReactAndroid/src/main/java/com/facebook/react/uimanager/UIImplementation.java
@@ -54,6 +54,14 @@
private final int[] mMeasureBuffer = new int[4];
private long mLastCalculateLayoutTime = 0;
protected @Nullable LayoutUpdateListener mLayoutUpdateListener;
/** Interface definition for a callback to be invoked when the layout has been updated */
public interface LayoutUpdateListener {
/** Called when the layout has been updated */
void onLayoutUpdated(ReactShadowNode root);
}
public UIImplementation(
ReactApplicationContext reactContext,
@@ -693,6 +701,10 @@ protected void updateViewHierarchy() {
} finally {
Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE);
}
if (mLayoutUpdateListener != null) {
mLayoutUpdateListener.onLayoutUpdated(cssRoot);
}
}
}
} finally {
@@ -1009,4 +1021,12 @@ public int resolveRootTagFromReactTag(int reactTag) {
public void enableLayoutCalculationForRootNode(int rootViewTag) {
this.mMeasuredRootNodes.add(rootViewTag);
}
public void setLayoutUpdateListener(LayoutUpdateListener listener) {
mLayoutUpdateListener = listener;
}
public void removeLayoutUpdateListener() {
mLayoutUpdateListener = null;
}
}

0 comments on commit 91372e8

Please sign in to comment.