/**
  * Add a new image/string ID to the set of images.
  *
  * @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.
  */
 @DSComment("From safe class list")
 @DSSafe(DSCat.SAFE_LIST)
 @DSGenerator(
     tool_name = "Doppelganger",
     tool_version = "2.0",
     generated_on = "2013-12-30 12:34:11.108 -0500",
     hash_original_method = "AF6407614B20F66E7E774377847CB658",
     hash_generated_method = "FBE12C8DC4EE2A8564D85027E19564BE")
 public void addState(int[] stateSet, Drawable drawable) {
   if (drawable != null) {
     mStateListState.addStateSet(stateSet, drawable);
     // in case the new state matches our current state...
     onStateChange(getState());
   }
 }
  @DSComment("From safe class list")
  @DSSafe(DSCat.SAFE_LIST)
  @DSGenerator(
      tool_name = "Doppelganger",
      tool_version = "2.0",
      generated_on = "2013-12-30 12:34:11.117 -0500",
      hash_original_method = "60A0EEC92FC73D4C3C226304BAFE6ED2",
      hash_generated_method = "881AEE96865DF1F601FB754CA0BA5763")
  @Override
  public void inflate(Resources r, XmlPullParser parser, AttributeSet attrs)
      throws XmlPullParserException, IOException {

    TypedArray a = r.obtainAttributes(attrs, com.android.internal.R.styleable.StateListDrawable);

    super.inflateWithAttributes(
        r, parser, a, com.android.internal.R.styleable.StateListDrawable_visible);

    mStateListState.setVariablePadding(
        a.getBoolean(com.android.internal.R.styleable.StateListDrawable_variablePadding, false));
    mStateListState.setConstantSize(
        a.getBoolean(com.android.internal.R.styleable.StateListDrawable_constantSize, false));
    mStateListState.setEnterFadeDuration(
        a.getInt(com.android.internal.R.styleable.StateListDrawable_enterFadeDuration, 0));
    mStateListState.setExitFadeDuration(
        a.getInt(com.android.internal.R.styleable.StateListDrawable_exitFadeDuration, 0));

    setDither(
        a.getBoolean(com.android.internal.R.styleable.StateListDrawable_dither, DEFAULT_DITHER));

    a.recycle();

    int type;

    final int innerDepth = parser.getDepth() + 1;
    int depth;
    while ((type = parser.next()) != XmlPullParser.END_DOCUMENT
        && ((depth = parser.getDepth()) >= innerDepth || type != XmlPullParser.END_TAG)) {
      if (type != XmlPullParser.START_TAG) {
        continue;
      }

      if (depth > innerDepth || !parser.getName().equals("item")) {
        continue;
      }

      int drawableRes = 0;

      int i;
      int j = 0;
      final int numAttrs = attrs.getAttributeCount();
      int[] states = new int[numAttrs];
      for (i = 0; i < numAttrs; i++) {
        final int stateResId = attrs.getAttributeNameResource(i);
        if (stateResId == 0) break;
        if (stateResId == com.android.internal.R.attr.drawable) {
          drawableRes = attrs.getAttributeResourceValue(i, 0);
        } else {
          states[j++] = attrs.getAttributeBooleanValue(i, false) ? stateResId : -stateResId;
        }
      }
      states = StateSet.trimStateSet(states, j);

      Drawable dr;
      if (drawableRes != 0) {
        dr = r.getDrawable(drawableRes);
      } else {
        while ((type = parser.next()) == XmlPullParser.TEXT) {}
        if (type != XmlPullParser.START_TAG) {
          throw new XmlPullParserException(
              parser.getPositionDescription()
                  + ": <item> tag requires a 'drawable' attribute or "
                  + "child tag defining a drawable");
        }
        dr = Drawable.createFromXmlInner(r, parser, attrs);
      }

      mStateListState.addStateSet(states, dr);
    }

    onStateChange(getState());
  }