diff options
| author | 2018-03-06 17:34:48 +0000 | |
|---|---|---|
| committer | 2018-03-06 17:34:48 +0000 | |
| commit | 1c6e3ba66dc0cb40d6639c3c6ff68103823909c0 (patch) | |
| tree | efa2dd4ac9f487fd1be911e43eb047d27b035c7f | |
| parent | e84c506fc3b7cc962fac407f465e46e8a6b969e8 (diff) | |
| parent | ffbf37e61141d0694d47565e60ff713f72c19532 (diff) | |
Merge "WallpaperColors.fromDrawable Drawable mutation" into pi-dev
| -rw-r--r-- | core/java/android/app/WallpaperColors.java | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/core/java/android/app/WallpaperColors.java b/core/java/android/app/WallpaperColors.java index a2864b9d83af..60e8a121dc45 100644 --- a/core/java/android/app/WallpaperColors.java +++ b/core/java/android/app/WallpaperColors.java @@ -21,6 +21,7 @@ import android.annotation.Nullable; import android.graphics.Bitmap; import android.graphics.Canvas; import android.graphics.Color; +import android.graphics.Rect; import android.graphics.drawable.Drawable; import android.os.Parcel; import android.os.Parcelable; @@ -107,6 +108,11 @@ public final class WallpaperColors implements Parcelable { * @param drawable Source where to extract from. */ public static WallpaperColors fromDrawable(Drawable drawable) { + if (drawable == null) { + throw new IllegalArgumentException("Drawable cannot be null"); + } + + Rect initialBounds = drawable.copyBounds(); int width = drawable.getIntrinsicWidth(); int height = drawable.getIntrinsicHeight(); @@ -126,6 +132,7 @@ public final class WallpaperColors implements Parcelable { final WallpaperColors colors = WallpaperColors.fromBitmap(bitmap); bitmap.recycle(); + drawable.setBounds(initialBounds); return colors; } |