Skip to content

Commit

Permalink
add UI Manager operations
Browse files Browse the repository at this point in the history
Reviewed By: achen1

Differential Revision: D5741087

fbshipit-source-id: f6b8f713cb3c4e48b417b47557a45ff9a4a5bf05
  • Loading branch information
aaronechiu authored and facebook-github-bot committed Sep 27, 2017
1 parent e9a090f commit 672db77
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 20 deletions.
Expand Up @@ -16,4 +16,9 @@ public void logMessage(DebugOverlayTag tag, String message, Object... args) {}

@Override
public void logMessage(DebugOverlayTag tag, String message) {}

@Override
public boolean shouldDisplayLogMessage(final DebugOverlayTag tag) {
return false;
}
}
Expand Up @@ -4,10 +4,10 @@

import com.facebook.debug.debugoverlay.model.DebugOverlayTag;

/** Interface to pass data to debugging tools. */
/** Interface to debugging tool. */
public interface Printer {

void logMessage(final DebugOverlayTag tag, final String message, Object... args);

void logMessage(final DebugOverlayTag tag, final String message);
boolean shouldDisplayLogMessage(final DebugOverlayTag tag);
}
Expand Up @@ -19,4 +19,9 @@ public class ReactDebugOverlayTags {
"Bridge Calls", "JS to Java calls (warning: this is spammy)", Color.MAGENTA);
public static final DebugOverlayTag NATIVE_MODULE =
new DebugOverlayTag("Native Module", "Native Module init", Color.rgb(0x80, 0x00, 0x80));
public static final DebugOverlayTag UI_MANAGER =
new DebugOverlayTag(
"UI Manager",
"UI Manager View Operations (requires restart\nwarning: this is spammy)",
Color.CYAN);
}
2 changes: 2 additions & 0 deletions ReactAndroid/src/main/java/com/facebook/react/uimanager/BUCK
Expand Up @@ -20,6 +20,8 @@ android_library(
react_native_dep("libraries/fbcore/src/main/java/com/facebook/common/logging:logging"),
react_native_dep("third-party/java/infer-annotations:infer-annotations"),
react_native_dep("third-party/java/jsr-305:jsr-305"),
react_native_target("java/com/facebook/debug/tags:tags"),
react_native_target("java/com/facebook/debug/holder:holder"),
react_native_target("java/com/facebook/react/animation:animation"),
react_native_target("java/com/facebook/react/bridge:bridge"),
react_native_target("java/com/facebook/react/common:common"),
Expand Down
Expand Up @@ -15,6 +15,8 @@
import android.content.ComponentCallbacks2;
import android.content.res.Configuration;
import com.facebook.common.logging.FLog;
import com.facebook.debug.holder.PrinterHolder;
import com.facebook.debug.tags.ReactDebugOverlayTags;
import com.facebook.react.animation.Animation;
import com.facebook.react.bridge.Callback;
import com.facebook.react.bridge.GuardedRunnable;
Expand Down Expand Up @@ -83,7 +85,8 @@ public interface CustomEventNamesResolver {

protected static final String NAME = "UIManager";

private static final boolean DEBUG = false;
private static final boolean DEBUG =
PrinterHolder.getPrinter().shouldDisplayLogMessage(ReactDebugOverlayTags.UI_MANAGER);

private final EventDispatcher mEventDispatcher;
private final Map<String, Object> mModuleConstants;
Expand Down Expand Up @@ -254,19 +257,21 @@ public void updateNodeSize(int nodeViewTag, int newWidth, int newHeight) {
@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);
String message =
"(UIManager.createView) tag: " + tag + ", class: " + className + ", props: " + props;
FLog.d(ReactConstants.TAG, message);
PrinterHolder.getPrinter().logMessage(ReactDebugOverlayTags.UI_MANAGER, message);
}
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);
String message =
"(UIManager.updateView) tag: " + tag + ", class: " + className + ", props: " + props;
FLog.d(ReactConstants.TAG, message);
PrinterHolder.getPrinter().logMessage(ReactDebugOverlayTags.UI_MANAGER, message);
}
mUIImplementation.updateView(tag, className, props);
}
Expand All @@ -291,14 +296,21 @@ public void manageChildren(
@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);
String message =
"(UIManager.manageChildren) tag: "
+ viewTag
+ ", moveFrom: "
+ moveFrom
+ ", moveTo: "
+ moveTo
+ ", addTags: "
+ addChildTags
+ ", atIndices: "
+ addAtIndices
+ ", removeFrom: "
+ removeFrom;
FLog.d(ReactConstants.TAG, message);
PrinterHolder.getPrinter().logMessage(ReactDebugOverlayTags.UI_MANAGER, message);
}
mUIImplementation.manageChildren(
viewTag,
Expand All @@ -321,9 +333,9 @@ public void setChildren(
int viewTag,
ReadableArray childrenTags) {
if (DEBUG) {
FLog.d(
ReactConstants.TAG,
"(UIManager.setChildren) tag: " + viewTag + ", children: " + childrenTags);
String message = "(UIManager.setChildren) tag: " + viewTag + ", children: " + childrenTags;
FLog.d(ReactConstants.TAG, message);
PrinterHolder.getPrinter().logMessage(ReactDebugOverlayTags.UI_MANAGER, message);
}
mUIImplementation.setChildren(viewTag, childrenTags);
}
Expand Down

0 comments on commit 672db77

Please sign in to comment.