/**
  * Gets the index of the drawable with the provided state set.
  *
  * @param stateSet the state set to look up
  * @return the index of the provided state set, or -1 if not found
  * @hide pending API council
  * @see #getStateDrawable(int)
  * @see #getStateSet(int)
  */
 @DSComment("From safe class list")
 @DSSafe(DSCat.SAFE_LIST)
 @DSSource({DSSourceKind.SENSITIVE_UNCATEGORIZED})
 @DSGenerator(
     tool_name = "Doppelganger",
     tool_version = "2.0",
     generated_on = "2013-12-30 12:34:11.128 -0500",
     hash_original_method = "410013485164C1DC2E995A85C1D3348C",
     hash_generated_method = "A49D72CF031B64EEE2017098206BB732")
 public int getStateDrawableIndex(int[] stateSet) {
   return mStateListState.indexOfStateSet(stateSet);
 }
 /**
  * Gets the drawable at an index.
  *
  * @param index The index of the drawable.
  * @return The drawable at the index.
  * @hide pending API council
  * @see #getStateCount()
  * @see #getStateSet(int)
  */
 @DSComment("From safe class list")
 @DSSafe(DSCat.SAFE_LIST)
 @DSSource({DSSourceKind.SENSITIVE_UNCATEGORIZED})
 @DSGenerator(
     tool_name = "Doppelganger",
     tool_version = "2.0",
     generated_on = "2013-12-30 12:34:11.126 -0500",
     hash_original_method = "266BB2A523416F0BDAD03984AE85B606",
     hash_generated_method = "9D08CC0A657EEDE0C0474D4E388F1A07")
 public Drawable getStateDrawable(int index) {
   return mStateListState.getChildren()[index];
 }
 /**
  * Gets the number of states contained in this drawable.
  *
  * @return The number of states contained in this drawable.
  * @hide pending API council
  * @see #getStateSet(int)
  * @see #getStateDrawable(int)
  */
 @DSComment("From safe class list")
 @DSSafe(DSCat.SAFE_LIST)
 @DSSource({DSSourceKind.SENSITIVE_UNCATEGORIZED})
 @DSGenerator(
     tool_name = "Doppelganger",
     tool_version = "2.0",
     generated_on = "2013-12-30 12:34:11.122 -0500",
     hash_original_method = "D9E3394F970F5413D258086831B5CB36",
     hash_generated_method = "0078239649DED5D4DAD52FF650246FE7")
 public int getStateCount() {
   return mStateListState.getChildCount();
 }
 @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.113 -0500",
     hash_original_method = "3B1FAED12170A69A129A87EF9824D4D4",
     hash_generated_method = "1CBF5E5B65D18CEA27C53CD9EBB977CC")
 @Override
 protected boolean onStateChange(int[] stateSet) {
   int idx = mStateListState.indexOfStateSet(stateSet);
   if (DEBUG)
     android.util.Log.i(
         TAG, "onStateChange " + this + " states " + Arrays.toString(stateSet) + " found " + idx);
   if (idx < 0) {
     idx = mStateListState.indexOfStateSet(StateSet.WILD_CARD);
   }
   if (selectDrawable(idx)) {
     return true;
   }
   return super.onStateChange(stateSet);
 }
 /**
  * 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.130 -0500",
     hash_original_method = "92CD1CD82DD5DEA6E7693E9ED80EE90B",
     hash_generated_method = "05DE6CC5FD086CD20355979CB63690F6")
 @Override
 public Drawable mutate() {
   if (!mMutated && super.mutate() == this) {
     final int[][] sets = mStateListState.mStateSets;
     final int count = sets.length;
     mStateListState.mStateSets = new int[count][];
     for (int i = 0; i < count; i++) {
       final int[] set = sets[i];
       if (set != null) {
         mStateListState.mStateSets[i] = set.clone();
       }
     }
     mMutated = true;
   }
   return this;
 }
  @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());
  }