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
This commit is contained in:
Andy Street 2016-07-05 04:27:10 -07:00 committed by Facebook Github Bot 7
parent c12db8045c
commit 950cefa2d6

View File

@ -14,6 +14,7 @@ import javax.annotation.Nullable;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import com.facebook.common.logging.FLog;
import com.facebook.react.animation.Animation; import com.facebook.react.animation.Animation;
import com.facebook.react.bridge.Callback; import com.facebook.react.bridge.Callback;
import com.facebook.react.bridge.LifecycleEventListener; 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.ReactMethod;
import com.facebook.react.bridge.ReadableArray; import com.facebook.react.bridge.ReadableArray;
import com.facebook.react.bridge.ReadableMap; 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.debug.NotThreadSafeViewHierarchyUpdateDebugListener;
import com.facebook.react.uimanager.events.EventDispatcher; import com.facebook.react.uimanager.events.EventDispatcher;
import com.facebook.systrace.Systrace; 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 // Keep in sync with ReactIOSTagHandles JS module - see that file for an explanation on why the
// increment here is 10 // increment here is 10
private static final int ROOT_VIEW_TAG_INCREMENT = 10; private static final int ROOT_VIEW_TAG_INCREMENT = 10;
private static final boolean DEBUG = false;
private final EventDispatcher mEventDispatcher; private final EventDispatcher mEventDispatcher;
private final Map<String, Object> mModuleConstants; private final Map<String, Object> mModuleConstants;
@ -166,18 +168,18 @@ public class UIManagerModule extends ReactContextBaseJavaModule implements
mUIImplementation.registerRootView(rootView, tag, width, height, themedRootContext); mUIImplementation.registerRootView(rootView, tag, width, height, themedRootContext);
rootView.setOnSizeChangedListener( rootView.setOnSizeChangedListener(
new SizeMonitoringFrameLayout.OnSizeChangedListener() { new SizeMonitoringFrameLayout.OnSizeChangedListener() {
@Override @Override
public void onSizeChanged(final int width, final int height, int oldW, int oldH) { public void onSizeChanged(final int width, final int height, int oldW, int oldH) {
getReactApplicationContext().runOnNativeModulesQueueThread( getReactApplicationContext().runOnNativeModulesQueueThread(
new Runnable() { new Runnable() {
@Override @Override
public void run() { public void run() {
updateRootNodeSize(tag, width, height); updateRootNodeSize(tag, width, height);
} }
}); });
} }
}); });
return tag; return tag;
} }
@ -195,11 +197,21 @@ public class UIManagerModule extends ReactContextBaseJavaModule implements
@ReactMethod @ReactMethod
public void createView(int tag, String className, int rootViewTag, ReadableMap props) { 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); mUIImplementation.createView(tag, className, rootViewTag, props);
} }
@ReactMethod @ReactMethod
public void updateView(int tag, String className, ReadableMap props) { 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); mUIImplementation.updateView(tag, className, props);
} }
@ -222,6 +234,16 @@ public class UIManagerModule extends ReactContextBaseJavaModule implements
@Nullable ReadableArray addChildTags, @Nullable ReadableArray addChildTags,
@Nullable ReadableArray addAtIndices, @Nullable ReadableArray addAtIndices,
@Nullable ReadableArray removeFrom) { @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( mUIImplementation.manageChildren(
viewTag, viewTag,
moveFrom, moveFrom,
@ -242,6 +264,9 @@ public class UIManagerModule extends ReactContextBaseJavaModule implements
public void setChildren( public void setChildren(
int viewTag, int viewTag,
ReadableArray childrenTags) { ReadableArray childrenTags) {
FLog.d(
ReactConstants.TAG,
"(UIManager.setChildren) tag: " + viewTag + ", children: " + childrenTags);
mUIImplementation.setChildren(viewTag, childrenTags); mUIImplementation.setChildren(viewTag, childrenTags);
} }
@ -336,10 +361,10 @@ public class UIManagerModule extends ReactContextBaseJavaModule implements
final ReadableArray point, final ReadableArray point,
final Callback callback) { final Callback callback) {
mUIImplementation.findSubviewIn( mUIImplementation.findSubviewIn(
reactTag, reactTag,
Math.round(PixelUtil.toPixelFromDIP(point.getDouble(0))), Math.round(PixelUtil.toPixelFromDIP(point.getDouble(0))),
Math.round(PixelUtil.toPixelFromDIP(point.getDouble(1))), Math.round(PixelUtil.toPixelFromDIP(point.getDouble(1))),
callback); callback);
} }
/** /**