コード例 #1
0
  @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());
  }
コード例 #2
0
  @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));

    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);
      }
      if (dr == null) {
        continue;
      }
      mStateListState.addStateSet(states, dr);
    }

    onStateChange(getState());
  }