From 950cefa2d669c30bac92dee948c597f87bdcfb5b Mon Sep 17 00:00:00 2001 From: Andy Street Date: Tue, 5 Jul 2016 04:27:10 -0700 Subject: [PATCH] Add debug statements to UIManager Summary: These are helpful for development and shouldn't affect anything when DEBUG=false Reviewed By: lexs Differential Revision: D3515015 fbshipit-source-id: 0bd5ff833f90fea8e70b3103eb1f9bc803bef27c --- .../react/uimanager/UIManagerModule.java | 59 +++++++++++++------ 1 file changed, 42 insertions(+), 17 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModule.java b/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModule.java index 12bbc1e3af1..b04af822a12 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModule.java +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModule.java @@ -14,6 +14,7 @@ import javax.annotation.Nullable; import java.util.List; import java.util.Map; +import com.facebook.common.logging.FLog; import com.facebook.react.animation.Animation; import com.facebook.react.bridge.Callback; import com.facebook.react.bridge.LifecycleEventListener; @@ -23,7 +24,7 @@ import com.facebook.react.bridge.ReactContextBaseJavaModule; import com.facebook.react.bridge.ReactMethod; import com.facebook.react.bridge.ReadableArray; import com.facebook.react.bridge.ReadableMap; -import com.facebook.react.uimanager.DisplayMetricsHolder; +import com.facebook.react.common.ReactConstants; import com.facebook.react.uimanager.debug.NotThreadSafeViewHierarchyUpdateDebugListener; import com.facebook.react.uimanager.events.EventDispatcher; import com.facebook.systrace.Systrace; @@ -64,6 +65,7 @@ public class UIManagerModule extends ReactContextBaseJavaModule implements // Keep in sync with ReactIOSTagHandles JS module - see that file for an explanation on why the // increment here is 10 private static final int ROOT_VIEW_TAG_INCREMENT = 10; + private static final boolean DEBUG = false; private final EventDispatcher mEventDispatcher; private final Map mModuleConstants; @@ -166,18 +168,18 @@ public class UIManagerModule extends ReactContextBaseJavaModule implements mUIImplementation.registerRootView(rootView, tag, width, height, themedRootContext); rootView.setOnSizeChangedListener( - new SizeMonitoringFrameLayout.OnSizeChangedListener() { - @Override - public void onSizeChanged(final int width, final int height, int oldW, int oldH) { - getReactApplicationContext().runOnNativeModulesQueueThread( - new Runnable() { - @Override - public void run() { - updateRootNodeSize(tag, width, height); - } - }); - } - }); + new SizeMonitoringFrameLayout.OnSizeChangedListener() { + @Override + public void onSizeChanged(final int width, final int height, int oldW, int oldH) { + getReactApplicationContext().runOnNativeModulesQueueThread( + new Runnable() { + @Override + public void run() { + updateRootNodeSize(tag, width, height); + } + }); + } + }); return tag; } @@ -195,11 +197,21 @@ public class UIManagerModule extends ReactContextBaseJavaModule implements @ReactMethod public void createView(int tag, String className, int rootViewTag, ReadableMap props) { + if (DEBUG) { + FLog.d( + ReactConstants.TAG, + "(UIManager.createView) tag: " + tag + ", class: " + className + ", props: " + props); + } mUIImplementation.createView(tag, className, rootViewTag, props); } @ReactMethod public void updateView(int tag, String className, ReadableMap props) { + if (DEBUG) { + FLog.d( + ReactConstants.TAG, + "(UIManager.updateView) tag: " + tag + ", class: " + className + ", props: " + props); + } mUIImplementation.updateView(tag, className, props); } @@ -222,6 +234,16 @@ public class UIManagerModule extends ReactContextBaseJavaModule implements @Nullable ReadableArray addChildTags, @Nullable ReadableArray addAtIndices, @Nullable ReadableArray removeFrom) { + if (DEBUG) { + FLog.d( + ReactConstants.TAG, + "(UIManager.manageChildren) tag: " + viewTag + + ", moveFrom: " + moveFrom + + ", moveTo: " + moveTo + + ", addTags: " + addChildTags + + ", atIndices: " + addAtIndices + + ", removeFrom: " + removeFrom); + } mUIImplementation.manageChildren( viewTag, moveFrom, @@ -242,6 +264,9 @@ public class UIManagerModule extends ReactContextBaseJavaModule implements public void setChildren( int viewTag, ReadableArray childrenTags) { + FLog.d( + ReactConstants.TAG, + "(UIManager.setChildren) tag: " + viewTag + ", children: " + childrenTags); mUIImplementation.setChildren(viewTag, childrenTags); } @@ -336,10 +361,10 @@ public class UIManagerModule extends ReactContextBaseJavaModule implements final ReadableArray point, final Callback callback) { mUIImplementation.findSubviewIn( - reactTag, - Math.round(PixelUtil.toPixelFromDIP(point.getDouble(0))), - Math.round(PixelUtil.toPixelFromDIP(point.getDouble(1))), - callback); + reactTag, + Math.round(PixelUtil.toPixelFromDIP(point.getDouble(0))), + Math.round(PixelUtil.toPixelFromDIP(point.getDouble(1))), + callback); } /**