Fix Nodes not having correct view managers externally

Reviewed By: ahmedre

Differential Revision: D4927963

fbshipit-source-id: f4993aa45f6313e814d03141f828d37eafade059
This commit is contained in:
Seth Kirby
2017-04-27 15:35:24 -07:00
committed by Facebook Github Bot
parent 6272ef87bc
commit c8bb422882
14 changed files with 207 additions and 143 deletions
@@ -9,29 +9,29 @@
package com.facebook.react.flat;
import javax.annotation.Nullable;
import java.util.Map;
import android.graphics.Rect;
import android.os.Build;
import com.facebook.react.bridge.JSApplicationIllegalArgumentException;
import com.facebook.react.bridge.ReadableArray;
import com.facebook.react.bridge.ReadableMap;
import com.facebook.react.common.MapBuilder;
import com.facebook.react.uimanager.PixelUtil;
import com.facebook.react.uimanager.PointerEvents;
import com.facebook.react.uimanager.ReactClippingViewGroupHelper;
import com.facebook.react.uimanager.ViewProps;
import com.facebook.react.uimanager.annotations.ReactProp;
import com.facebook.react.uimanager.ReactClippingViewGroupHelper;
import com.facebook.react.views.view.ReactDrawableHelper;
import javax.annotation.Nullable;
import java.util.Map;
/**
* ViewManager that creates instances of RCTView.
*/
public final class RCTViewManager extends FlatViewManager {
/* package */ static final String REACT_CLASS = ViewProps.VIEW_CLASS_NAME;
private static final int[] TMP_INT_ARRAY = new int[2];
private static final int CMD_HOTSPOT_UPDATE = 1;
@@ -39,7 +39,7 @@ public final class RCTViewManager extends FlatViewManager {
@Override
public String getName() {
return ViewProps.VIEW_CLASS_NAME;
return REACT_CLASS;
}
public Map<String, Integer> getCommandsMap() {
@@ -59,19 +59,19 @@ public final class RCTViewManager extends FlatViewManager {
@ReactProp(name = "nativeBackgroundAndroid")
public void setHotspot(FlatViewGroup view, @Nullable ReadableMap bg) {
view.setHotspot(bg == null ?
null : ReactDrawableHelper.createDrawableFromJSDescription(view.getContext(), bg));
null : ReactDrawableHelper.createDrawableFromJSDescription(view.getContext(), bg));
}
@Override
public void receiveCommand(
FlatViewGroup view,
int commandId,
@Nullable ReadableArray args) {
FlatViewGroup view,
int commandId,
@Nullable ReadableArray args) {
switch (commandId) {
case CMD_HOTSPOT_UPDATE: {
if (args == null || args.size() != 2) {
throw new JSApplicationIllegalArgumentException(
"Illegal number of arguments for 'updateHotspot' command");
"Illegal number of arguments for 'updateHotspot' command");
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
view.getLocationOnScreen(TMP_INT_ARRAY);
@@ -84,7 +84,7 @@ public final class RCTViewManager extends FlatViewManager {
case CMD_SET_PRESSED: {
if (args == null || args.size() != 1) {
throw new JSApplicationIllegalArgumentException(
"Illegal number of arguments for 'setPressed' command");
"Illegal number of arguments for 'setPressed' command");
}
view.setPressed(args.getBoolean(0));
break;
@@ -94,8 +94,8 @@ public final class RCTViewManager extends FlatViewManager {
@ReactProp(name = ViewProps.NEEDS_OFFSCREEN_ALPHA_COMPOSITING)
public void setNeedsOffscreenAlphaCompositing(
FlatViewGroup view,
boolean needsOffscreenAlphaCompositing) {
FlatViewGroup view,
boolean needsOffscreenAlphaCompositing) {
view.setNeedsOffscreenAlphaCompositing(needsOffscreenAlphaCompositing);
}
@@ -132,10 +132,10 @@ public final class RCTViewManager extends FlatViewManager {
view.setHitSlopRect(null);
} else {
view.setHitSlopRect(new Rect(
(int) PixelUtil.toPixelFromDIP(hitSlop.getDouble("left")),
(int) PixelUtil.toPixelFromDIP(hitSlop.getDouble("top")),
(int) PixelUtil.toPixelFromDIP(hitSlop.getDouble("right")),
(int) PixelUtil.toPixelFromDIP(hitSlop.getDouble("bottom"))
(int) PixelUtil.toPixelFromDIP(hitSlop.getDouble("left")),
(int) PixelUtil.toPixelFromDIP(hitSlop.getDouble("top")),
(int) PixelUtil.toPixelFromDIP(hitSlop.getDouble("right")),
(int) PixelUtil.toPixelFromDIP(hitSlop.getDouble("bottom"))
));
}
}