Skip to content

Commit 662aa06

Browse files
wcshicketcham
authored andcommitted
Add null check before access attribute set.
PiperOrigin-RevId: 203830200
1 parent d5d11a7 commit 662aa06

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

lib/java/com/google/android/material/chip/ChipDrawable.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ private void loadFromAttributes(
377377
setChipIconVisible(a.getBoolean(R.styleable.Chip_chipIconVisible, false));
378378
// If the user explicitly sets the deprecated attribute (chipIconEnabled) but NOT the
379379
// replacement attribute (chipIconVisible), use the value specified in the deprecated attribute.
380-
if (attrs.getAttributeValue(NAMESPACE_APP, "chipIconEnabled") != null
380+
if (attrs != null && attrs.getAttributeValue(NAMESPACE_APP, "chipIconEnabled") != null
381381
&& attrs.getAttributeValue(NAMESPACE_APP, "chipIconVisible") == null) {
382382
setChipIconVisible(a.getBoolean(R.styleable.Chip_chipIconEnabled, false));
383383
}
@@ -389,7 +389,7 @@ private void loadFromAttributes(
389389
// If the user explicitly sets the deprecated attribute (closeIconEnabled) but NOT the
390390
// replacement attribute (closeIconVisible), use the value specified in the deprecated
391391
// attribute.
392-
if (attrs.getAttributeValue(NAMESPACE_APP, "closeIconEnabled") != null
392+
if (attrs != null && attrs.getAttributeValue(NAMESPACE_APP, "closeIconEnabled") != null
393393
&& attrs.getAttributeValue(NAMESPACE_APP, "closeIconVisible") == null) {
394394
setCloseIconVisible(a.getBoolean(R.styleable.Chip_closeIconEnabled, false));
395395
}
@@ -403,7 +403,7 @@ private void loadFromAttributes(
403403
// If the user explicitly sets the deprecated attribute (checkedIconEnabled) but NOT the
404404
// replacement attribute (checkedIconVisible), use the value specified in the deprecated
405405
// attribute.
406-
if (attrs.getAttributeValue(NAMESPACE_APP, "checkedIconEnabled") != null
406+
if (attrs != null && attrs.getAttributeValue(NAMESPACE_APP, "checkedIconEnabled") != null
407407
&& attrs.getAttributeValue(NAMESPACE_APP, "checkedIconVisible") == null) {
408408
setCheckedIconVisible(a.getBoolean(R.styleable.Chip_checkedIconEnabled, false));
409409
}

0 commit comments

Comments
 (0)