|
37 | 37 | import static com.facebook.litho.ThreadUtils.assertMainThread;
|
38 | 38 | import static com.facebook.litho.ThreadUtils.isMainThread;
|
39 | 39 | import static com.facebook.litho.config.ComponentsConfiguration.DEFAULT_BACKGROUND_THREAD_PRIORITY;
|
40 |
| -import static com.facebook.litho.debugutils.LayoutCalculationDebugUtilsKt.flash; |
41 | 40 | import static com.facebook.rendercore.instrumentation.HandlerInstrumenter.instrumentHandler;
|
42 | 41 |
|
43 | 42 | import android.content.Context;
|
| 43 | +import android.graphics.Color; |
| 44 | +import android.graphics.drawable.Drawable; |
| 45 | +import android.graphics.drawable.PaintDrawable; |
44 | 46 | import android.os.Handler;
|
45 | 47 | import android.os.HandlerThread;
|
46 | 48 | import android.os.Looper;
|
@@ -1125,7 +1127,7 @@ public boolean isReconciliationEnabled() {
|
1125 | 1127 | return mLithoConfiguration.isReconciliationEnabled;
|
1126 | 1128 | }
|
1127 | 1129 |
|
1128 |
| - synchronized @Nullable Component getRoot() { |
| 1130 | + public synchronized @Nullable Component getRoot() { |
1129 | 1131 | return mRoot;
|
1130 | 1132 | }
|
1131 | 1133 |
|
@@ -1180,6 +1182,19 @@ private void preAllocateMountContent(boolean shouldPreallocatePerMountSpec) {
|
1180 | 1182 | }
|
1181 | 1183 | }
|
1182 | 1184 |
|
| 1185 | + public void setRootSync(@Nullable Component root) { |
| 1186 | + setRootAndSizeSpecAndWrapper( |
| 1187 | + root, |
| 1188 | + SIZE_UNINITIALIZED, |
| 1189 | + SIZE_UNINITIALIZED, |
| 1190 | + false /* isAsync */, |
| 1191 | + null /* output */, |
| 1192 | + CalculateLayoutSource.SET_ROOT_SYNC, |
| 1193 | + INVALID_LAYOUT_VERSION, |
| 1194 | + null, |
| 1195 | + null); |
| 1196 | + } |
| 1197 | + |
1183 | 1198 | public void setRootAsync(@Nullable Component root) {
|
1184 | 1199 | setRootAndSizeSpecAndWrapper(
|
1185 | 1200 | root,
|
@@ -2980,6 +2995,21 @@ EventHandlersController getEventHandlersController() {
|
2980 | 2995 | return mTreeState.getEventHandlersController();
|
2981 | 2996 | }
|
2982 | 2997 |
|
| 2998 | + private static void flash(View view) { |
| 2999 | + Drawable d = new PaintDrawable(Color.RED); |
| 3000 | + d.setAlpha(128); |
| 3001 | + view.post( |
| 3002 | + () -> { |
| 3003 | + d.setBounds(0, 0, view.getWidth(), view.getHeight()); |
| 3004 | + view.getOverlay().add(d); |
| 3005 | + view.postDelayed( |
| 3006 | + () -> { |
| 3007 | + view.getOverlay().remove(d); |
| 3008 | + }, |
| 3009 | + 500); |
| 3010 | + }); |
| 3011 | + } |
| 3012 | + |
2983 | 3013 | class LayoutStateFuture extends TreeFuture<LayoutState> {
|
2984 | 3014 | private final Object loggerMutex = new Object();
|
2985 | 3015 | private final ComponentContext context;
|
|
0 commit comments