diff --git a/android/src/main/java/com/facebook/flipper/plugins/uidebugger/descriptors/TextViewDescriptor.kt b/android/src/main/java/com/facebook/flipper/plugins/uidebugger/descriptors/TextViewDescriptor.kt index 35e4c35b9..22b07fa5e 100644 --- a/android/src/main/java/com/facebook/flipper/plugins/uidebugger/descriptors/TextViewDescriptor.kt +++ b/android/src/main/java/com/facebook/flipper/plugins/uidebugger/descriptors/TextViewDescriptor.kt @@ -21,7 +21,6 @@ object TextViewDescriptor : ChainedDescriptor() { node: TextView, attributeSections: MutableMap ) { - val typeface = node.typeface val props = mutableMapOf( @@ -29,18 +28,21 @@ object TextViewDescriptor : ChainedDescriptor() { "textSize" to InspectableValue.Number(node.textSize, false), "textColor" to InspectableValue.Color(node.getTextColors().getDefaultColor(), false)) - val typeFace = - mutableMapOf( - "isBold" to InspectableValue.Boolean(typeface.isBold, false), - "isItalic" to InspectableValue.Boolean(typeface.isItalic, false), - ) + val typeface = node.typeface + if (typeface != null) { + val typeFaceProp = + mutableMapOf( + "isBold" to InspectableValue.Boolean(typeface.isBold, false), + "isItalic" to InspectableValue.Boolean(typeface.isItalic, false), + ) - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { - typeFace["weight"] = InspectableValue.Number(typeface.weight, false) + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { + typeFaceProp["weight"] = InspectableValue.Number(typeface.weight, false) + } + + props["typeface"] = InspectableObject(typeFaceProp) } - props["typeface"] = InspectableObject(typeFace) - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { props["minLines"] = InspectableValue.Number(node.minLines, false) props["maxLines"] = InspectableValue.Number(node.maxLines, false)