mirror of
https://github.com/status-im/react-native.git
synced 2025-01-28 02:04:55 +00:00
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:
parent
c12db8045c
commit
950cefa2d6
@ -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<String, Object> 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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user