Merge "WallpaperColors.fromDrawable Drawable mutation" into pi-dev

am: 1c6e3ba66d

Change-Id: I75f1594b938679919d531ff9b27b43e0a59a433d
This commit is contained in:
Lucas Dupin
2018-03-06 17:56:39 +00:00
committed by android-build-merger

View File

@@ -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;
}