Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit bf1aee7b authored by Alan Viverette's avatar Alan Viverette Committed by Android (Google) Code Review
Browse files

Merge "Handle null argument to GradientDrawable.setColor() and setStroke()"

parents 365c55cb 7c263c6e
Loading
Loading
Loading
Loading
+20 −10
Original line number Diff line number Diff line
@@ -288,12 +288,16 @@ public class GradientDrawable extends Drawable {
     */
    public void setStroke(
            int width, ColorStateList colorStateList, float dashWidth, float dashGap) {
        if (colorStateList == null) {
            setStroke(width, Color.TRANSPARENT, dashWidth, dashGap);
        } else {
            mGradientState.setStroke(width, colorStateList, dashWidth, dashGap);

            final int[] stateSet = getState();
            final int color = colorStateList.getColorForState(stateSet, 0);
            setStrokeInternal(width, color, dashWidth, dashGap);
        }
    }

    private void setStrokeInternal(int width, int color, float dashWidth, float dashGap) {
        if (mStrokePaint == null)  {
@@ -675,7 +679,9 @@ public class GradientDrawable extends Drawable {

    /**
     * Changes this drawable to use a single color state list instead of a
     * gradient.
     * gradient. Calling this method with a null argument will clear the color
     * and is equivalent to calling {@link #setColor(int)} with the argument
     * {@link Color#TRANSPARENT}.
     * <p>
     * <strong>Note</strong>: changing color will affect all instances of a
     * drawable loaded from a resource. It is recommended to invoke
@@ -685,11 +691,15 @@ public class GradientDrawable extends Drawable {
     * @see #mutate()
     */
    public void setColor(ColorStateList colorStateList) {
        if (colorStateList == null) {
            setColor(Color.TRANSPARENT);
        } else {
            final int color = colorStateList.getColorForState(getState(), 0);
            mGradientState.setColorStateList(colorStateList);
            mFillPaint.setColor(color);
            invalidateSelf();
        }
    }

    @Override
    public boolean onStateChange(int[] stateSet) {
@@ -1295,7 +1305,7 @@ public class GradientDrawable extends Drawable {
        }
        
        public void setSolidColor(int argb) {
            mHasSolidColor = true;
            mHasSolidColor = argb != Color.TRANSPARENT;
            mSolidColor = argb;
            mColors = null;
            mColorStateList = null;