Add a null check to UserAvatarView.setBitmap

Adds a null check for the bitmap to set. Resets the paint's shader
in case of a null bitmap to release any previous image.

Change-Id: I1adf3c8ef44522a593fe3f25726b6c83120d7556
This commit is contained in:
Andreas Gampe
2014-06-19 23:51:12 -07:00
parent 5ff885cd3b
commit b325ce8203

View File

@@ -90,8 +90,12 @@ public class UserAvatarView extends View {
public void setBitmap(Bitmap bitmap) {
setDrawable(null);
mBitmap = bitmap;
mBitmapPaint.setShader(new BitmapShader(
bitmap, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP));
if (mBitmap != null) {
mBitmapPaint.setShader(new BitmapShader(
bitmap, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP));
} else {
mBitmapPaint.setShader(null);
}
configureBounds();
invalidate();
}