From 2cdcd9bad9171828926235fccf04be42214e8707 Mon Sep 17 00:00:00 2001 From: Pascal Hartig Date: Tue, 7 May 2019 12:34:47 -0700 Subject: [PATCH] Fix inspector crash on null colors Summary: Quick fix for layout plugin and export crashing when encountering nullable props for colors and drawables like `refreshProgressBarBackgroundColor` on `RecyclerSpec`. The rendered view in the inspector is not great right now, but better than a crash. Working on the correct representation next. Reviewed By: jknoxville Differential Revision: D15241151 fbshipit-source-id: 3754dee8861a442127a34d7c3211d223c5f390c1 --- .../java/com/facebook/flipper/plugins/litho/DataUtils.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/android/src/main/java/com/facebook/flipper/plugins/litho/DataUtils.java b/android/src/main/java/com/facebook/flipper/plugins/litho/DataUtils.java index 72747d16b..1ef5f0999 100644 --- a/android/src/main/java/com/facebook/flipper/plugins/litho/DataUtils.java +++ b/android/src/main/java/com/facebook/flipper/plugins/litho/DataUtils.java @@ -25,7 +25,6 @@ import javax.annotation.Nullable; public class DataUtils { - @Nullable static List> getPropData(Object node) throws Exception { final FlipperObject.Builder props = new FlipperObject.Builder(); @@ -49,10 +48,10 @@ public class DataUtils { switch (annotation.resType()) { case COLOR: - props.put(f.getName(), fromColor((Integer) f.get(node))); + props.put(f.getName(), f.get(node) == null ? "null" : fromColor((Integer) f.get(node))); break; case DRAWABLE: - props.put(f.getName(), fromDrawable((Drawable) f.get(node))); + props.put(f.getName(), f.get(node) == null ? "null" : fromDrawable((Drawable) f.get(node))); break; default: if (f.get(node) != null