From ce0edca620d49597aa73c71a68b70efa170bc828 Mon Sep 17 00:00:00 2001 From: Eli White Date: Mon, 2 Mar 2020 15:07:50 -0800 Subject: [PATCH] Update ReactPropertyProcessor to handle new color objects Summary: D19837753 updated the native platforms to support complex color objects however the diff failed to build when going through this code path (as we do at Facebook). This updates the automatic PropSetter classes to go through the new Color handler. Changelog: [Internal] (Note: this ignores all push blocking failures!) Reviewed By: mdvacca Differential Revision: D20169335 fbshipit-source-id: 8eb9c8b48b1840832b3aec9ffcb83c3cf614ce0e --- .../processing/ReactPropertyProcessor.java | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/processing/ReactPropertyProcessor.java b/ReactAndroid/src/main/java/com/facebook/react/processing/ReactPropertyProcessor.java index 4de393afb11..09de068f02a 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/processing/ReactPropertyProcessor.java +++ b/ReactAndroid/src/main/java/com/facebook/react/processing/ReactPropertyProcessor.java @@ -348,7 +348,7 @@ public class ReactPropertyProcessor extends AbstractProcessor { if (BOXED_PRIMITIVES.contains(propertyInfo.propertyType)) { builder.add("value == null ? null : "); } - getPropertyExtractor(propertyInfo, builder); + getPropertyExtractor(info, propertyInfo, builder); builder.addStatement(")"); builder.addStatement("break").unindent(); @@ -359,7 +359,7 @@ public class ReactPropertyProcessor extends AbstractProcessor { } private static CodeBlock.Builder getPropertyExtractor( - PropertyInfo info, CodeBlock.Builder builder) { + ClassInfo classInfo, PropertyInfo info, CodeBlock.Builder builder) { TypeName propertyType = info.propertyType; if (propertyType.equals(STRING_TYPE)) { return builder.add("($L)value", STRING_TYPE); @@ -394,7 +394,18 @@ public class ReactPropertyProcessor extends AbstractProcessor { return builder.add("value == null ? $Lf : ((Double)value).floatValue()", defaultFloat); } } - if (propertyType.equals(TypeName.INT)) { + if ("Color".equals(info.mProperty.customType())) { + switch (classInfo.getType()) { + case VIEW_MANAGER: + return builder.add( + "$T.getColor(value, view.getContext())", + com.facebook.react.bridge.ColorPropConverter.class); + case SHADOW_NODE: + return builder.add( + "$T.getColor(value, node.getThemedContext())", + com.facebook.react.bridge.ColorPropConverter.class); + } + } else if (propertyType.equals(TypeName.INT)) { return builder.add( "value == null ? $L : ((Double)value).intValue()", info.mProperty.defaultInt()); }