Prevent NPE in Launcher when an icon cannot be found.
Bug #2509023
Change-Id: I053c7c9a37ed4aeb4d78a9f62dfdeea09a3959aa
diff --git a/src/com/android/launcher2/FastBitmapDrawable.java b/src/com/android/launcher2/FastBitmapDrawable.java
index 850535e..226d6d8 100644
--- a/src/com/android/launcher2/FastBitmapDrawable.java
+++ b/src/com/android/launcher2/FastBitmapDrawable.java
@@ -24,9 +24,17 @@
class FastBitmapDrawable extends Drawable {
private Bitmap mBitmap;
+ private int mWidth;
+ private int mHeight;
FastBitmapDrawable(Bitmap b) {
mBitmap = b;
+ if (b != null) {
+ mWidth = mBitmap.getWidth();
+ mHeight = mBitmap.getHeight();
+ } else {
+ mWidth = mHeight = 0;
+ }
}
@Override
@@ -49,26 +57,32 @@
@Override
public int getIntrinsicWidth() {
- return mBitmap.getWidth();
+ return mWidth;
}
@Override
public int getIntrinsicHeight() {
- return mBitmap.getHeight();
+ return mHeight;
}
@Override
public int getMinimumWidth() {
- return mBitmap.getWidth();
+ return mWidth;
}
@Override
public int getMinimumHeight() {
- return mBitmap.getHeight();
+ return mHeight;
}
public void setBitmap(Bitmap b) {
mBitmap = b;
+ if (b != null) {
+ mWidth = mBitmap.getWidth();
+ mHeight = mBitmap.getHeight();
+ } else {
+ mWidth = mHeight = 0;
+ }
}
public Bitmap getBitmap() {