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

Commit e44e7fd6 authored by Nader Jawad's avatar Nader Jawad
Browse files

Updated documentation of StateListDrawable#addState in order to indicate

that sharing a Drawable across multiple Views/Drawables can lead to
undefined rendering behavior

Bug: 70594326
Test: Re-ran CtsGraphicsTestCases

Change-Id: Ia6923886c809b6d81ead43becd8c725ae79ee999
parent aab0b2f0
Loading
Loading
Loading
Loading
+12 −10
Original line number Diff line number Diff line
@@ -16,6 +16,14 @@

package android.graphics.drawable;

import android.annotation.NonNull;
import android.annotation.Nullable;
import android.content.res.Resources;
import android.content.res.Resources.Theme;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.util.StateSet;

import com.android.internal.R;

import org.xmlpull.v1.XmlPullParser;
@@ -24,14 +32,6 @@ import org.xmlpull.v1.XmlPullParserException;
import java.io.IOException;
import java.util.Arrays;

import android.annotation.NonNull;
import android.annotation.Nullable;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.content.res.Resources.Theme;
import android.util.AttributeSet;
import android.util.StateSet;

/**
 * Lets you assign a number of graphic images to a single Drawable and swap out the visible item by a string
 * ID value.
@@ -73,9 +73,11 @@ public class StateListDrawable extends DrawableContainer {
    /**
     * Add a new image/string ID to the set of images.
     *
     * @param stateSet - An array of resource Ids to associate with the image.
     * @param stateSet An array of resource Ids to associate with the image.
     *                 Switch to this image by calling setState().
     * @param drawable -The image to show.
     * @param drawable The image to show. Note this must be a unique Drawable that is not shared
     *                 between any other View or Drawable otherwise the results are
     *                 undefined and can lead to unexpected rendering behavior
     */
    public void addState(int[] stateSet, Drawable drawable) {
        if (drawable != null) {