Skip to content

Commit 4b941f0

Browse files
adampAndroid (Google) Code Review
authored andcommitted
Merge "Fix bug 6906134" into jb-mr1-dev
2 parents 9f52da2 + c1eea13 commit 4b941f0

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

core/java/com/android/internal/view/menu/ActionMenuItemView.java

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -141,19 +141,21 @@ private void updateTextButtonVisibility() {
141141

142142
public void setIcon(Drawable icon) {
143143
mIcon = icon;
144-
int width = icon.getIntrinsicWidth();
145-
int height = icon.getIntrinsicHeight();
146-
if (width > mMaxIconSize) {
147-
final float scale = (float) mMaxIconSize / width;
148-
width = mMaxIconSize;
149-
height *= scale;
150-
}
151-
if (height > mMaxIconSize) {
152-
final float scale = (float) mMaxIconSize / height;
153-
height = mMaxIconSize;
154-
width *= scale;
144+
if (icon != null) {
145+
int width = icon.getIntrinsicWidth();
146+
int height = icon.getIntrinsicHeight();
147+
if (width > mMaxIconSize) {
148+
final float scale = (float) mMaxIconSize / width;
149+
width = mMaxIconSize;
150+
height *= scale;
151+
}
152+
if (height > mMaxIconSize) {
153+
final float scale = (float) mMaxIconSize / height;
154+
height = mMaxIconSize;
155+
width *= scale;
156+
}
157+
icon.setBounds(0, 0, width, height);
155158
}
156-
icon.setBounds(0, 0, width, height);
157159
setCompoundDrawables(icon, null, null, null);
158160

159161
updateTextButtonVisibility();

0 commit comments

Comments
 (0)