Handle bad icon resources.
Change-Id: I87c5fe68ad8016596068ba7889f3b6d36da3386b
This commit is contained in:
@@ -32,6 +32,7 @@ public class StatusBarIconView extends AnimatedImageView {
|
|||||||
|
|
||||||
private StatusBarIcon mIcon;
|
private StatusBarIcon mIcon;
|
||||||
@ViewDebug.ExportedProperty private String mSlot;
|
@ViewDebug.ExportedProperty private String mSlot;
|
||||||
|
@ViewDebug.ExportedProperty private boolean mError;
|
||||||
|
|
||||||
public StatusBarIconView(Context context, String slot) {
|
public StatusBarIconView(Context context, String slot) {
|
||||||
super(context);
|
super(context);
|
||||||
@@ -52,24 +53,37 @@ public class StatusBarIconView extends AnimatedImageView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void set(StatusBarIcon icon) {
|
public void set(StatusBarIcon icon) {
|
||||||
final boolean iconEquals = mIcon != null
|
error: {
|
||||||
&& streq(mIcon.iconPackage, icon.iconPackage)
|
final boolean iconEquals = !mError
|
||||||
&& mIcon.iconId == icon.iconId;
|
&& mIcon != null
|
||||||
final boolean levelEquals = iconEquals
|
&& streq(mIcon.iconPackage, icon.iconPackage)
|
||||||
&& mIcon.iconLevel == icon.iconLevel;
|
&& mIcon.iconId == icon.iconId;
|
||||||
final boolean visibilityEquals = mIcon != null
|
final boolean levelEquals = !mError
|
||||||
&& mIcon.visible == icon.visible;
|
&& iconEquals
|
||||||
if (!iconEquals) {
|
&& mIcon.iconLevel == icon.iconLevel;
|
||||||
setImageDrawable(getIcon(icon));
|
final boolean visibilityEquals = !mError
|
||||||
// TODO: What if getIcon returns null?
|
&& mIcon != null
|
||||||
|
&& mIcon.visible == icon.visible;
|
||||||
|
mError = false;
|
||||||
|
if (!iconEquals) {
|
||||||
|
Drawable drawable = getIcon(icon);
|
||||||
|
if (drawable == null) {
|
||||||
|
mError = true;
|
||||||
|
break error;
|
||||||
|
}
|
||||||
|
setImageDrawable(drawable);
|
||||||
|
}
|
||||||
|
if (!levelEquals) {
|
||||||
|
setImageLevel(icon.iconLevel);
|
||||||
|
}
|
||||||
|
if (!visibilityEquals) {
|
||||||
|
setVisibility(icon.visible ? VISIBLE : GONE);
|
||||||
|
}
|
||||||
|
mIcon = icon.clone();
|
||||||
}
|
}
|
||||||
if (!levelEquals) {
|
if (mError) {
|
||||||
setImageLevel(icon.iconLevel);
|
setVisibility(GONE);
|
||||||
}
|
}
|
||||||
if (!visibilityEquals) {
|
|
||||||
setVisibility(icon.visible ? VISIBLE : GONE);
|
|
||||||
}
|
|
||||||
mIcon = icon.clone();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -122,6 +122,16 @@ public class NotificationTestList extends TestActivity
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
new Test("Bad Icon") {
|
||||||
|
public void run() {
|
||||||
|
mNM.notify(1, new Notification(NotificationTestList.this,
|
||||||
|
R.layout.chrono_notification, /* not a drawable! */
|
||||||
|
null, System.currentTimeMillis()-(1000*60*60*24),
|
||||||
|
"(453) 123-2328",
|
||||||
|
"", null));
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
new Test("Bad resource #2") {
|
new Test("Bad resource #2") {
|
||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user