Add callback for UIImplementation layout updates

Differential Revision: D6063839

fbshipit-source-id: ae08fd2fc6c6365813b8077efe14990a0355a5c7
This commit is contained in:
Andrew Chen (Eng) 2017-10-17 07:36:16 -07:00 коммит произвёл Facebook Github Bot
Родитель 47bfbbb1d3
Коммит 91372e8f9a
1 изменённых файлов: 20 добавлений и 0 удалений

Просмотреть файл

@ -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,
@ -693,6 +701,10 @@ public class UIImplementation {
} finally {
Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE);
}
if (mLayoutUpdateListener != null) {
mLayoutUpdateListener.onLayoutUpdated(cssRoot);
}
}
}
} finally {
@ -1009,4 +1021,12 @@ public class UIImplementation {
public void enableLayoutCalculationForRootNode(int rootViewTag) {
this.mMeasuredRootNodes.add(rootViewTag);
}
public void setLayoutUpdateListener(LayoutUpdateListener listener) {
mLayoutUpdateListener = listener;
}
public void removeLayoutUpdateListener() {
mLayoutUpdateListener = null;
}
}