From 14516dba6230765639fe1db3d8136348bd5d9c8f Mon Sep 17 00:00:00 2001 From: Nader Jawad Date: Wed, 4 Apr 2018 14:45:43 -0700 Subject: [PATCH] Updated GradientDrawable setColor(ColorStateList) implementation to match corresponding documentation to fall back to setColor(Color.TRANSPARENT) in the event that null is passed as the ColorStateList parameter Refactored implementation to directly call setColor(Color.TRANSPARENT) if setColor(null) is invoked, otherwise configure the solid colors and the fill Paint color to the ColorStateList and resolved color for the given state Bug: 64951083 Test: Compiled, flashed an updated build of master onto taimen and re-ran tests with updated implementation in GradientDrawableTest Change-Id: Ia7e9a995fc78e49d601931ca6af81470d90f8439 --- .../android/graphics/drawable/GradientDrawable.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/graphics/java/android/graphics/drawable/GradientDrawable.java b/graphics/java/android/graphics/drawable/GradientDrawable.java index dfdddb2a599aa..25673cdcba1e4 100644 --- a/graphics/java/android/graphics/drawable/GradientDrawable.java +++ b/graphics/java/android/graphics/drawable/GradientDrawable.java @@ -930,16 +930,15 @@ public class GradientDrawable extends Drawable { * @see #getColor */ public void setColor(@Nullable ColorStateList colorStateList) { - mGradientState.setSolidColors(colorStateList); - final int color; if (colorStateList == null) { - color = Color.TRANSPARENT; + setColor(Color.TRANSPARENT); } else { final int[] stateSet = getState(); - color = colorStateList.getColorForState(stateSet, 0); + final int color = colorStateList.getColorForState(stateSet, 0); + mGradientState.setSolidColors(colorStateList); + mFillPaint.setColor(color); + invalidateSelf(); } - mFillPaint.setColor(color); - invalidateSelf(); } /**