Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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 91372e8
Showing 1 changed file with 20 additions and 0 deletions.
Expand Up @@ -54,6 +54,14 @@ public class UIImplementation {
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,
Expand Down Expand Up @@ -693,6 +701,10 @@ protected void updateViewHierarchy() {
} finally {
Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE);
}

if (mLayoutUpdateListener != null) {
mLayoutUpdateListener.onLayoutUpdated(cssRoot);
}
}
}
} finally {
Expand Down Expand Up @@ -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.