From 2fe051aef20ccbe73b5565910a699ddc65a6ec84 Mon Sep 17 00:00:00 2001 From: Balys Valentukevicius Date: Tue, 7 Oct 2014 15:48:17 +0100 Subject: [PATCH] Null check before setting drawable padding --- .../com/balysv/materialmenu/MaterialMenuView.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/library/src/main/java/com/balysv/materialmenu/MaterialMenuView.java b/library/src/main/java/com/balysv/materialmenu/MaterialMenuView.java index 60c12d5..aabdf9b 100644 --- a/library/src/main/java/com/balysv/materialmenu/MaterialMenuView.java +++ b/library/src/main/java/com/balysv/materialmenu/MaterialMenuView.java @@ -188,11 +188,13 @@ public void onRestoreInstanceState(Parcelable state) { } private void adjustDrawablePadding() { - drawable.setBounds( - 0, 0, - drawable.getIntrinsicWidth() + getPaddingLeft() + getPaddingRight(), - drawable.getIntrinsicHeight() + getPaddingTop() + getPaddingBottom() - ); + if (drawable != null) { + drawable.setBounds( + 0, 0, + drawable.getIntrinsicWidth() + getPaddingLeft() + getPaddingRight(), + drawable.getIntrinsicHeight() + getPaddingTop() + getPaddingBottom() + ); + } } private TypedArray getTypedArray(Context context, AttributeSet attributeSet, int[] attr) {