Exemplo n.º 1
0
 @Override
 public ConstantState getConstantState() {
   if (mInsetState.canConstantState()) {
     mInsetState.mChangingConfigurations = getChangingConfigurations();
     return mInsetState;
   }
   return null;
 }
Exemplo n.º 2
0
  @Override
  public void inflate(Resources r, XmlPullParser parser, AttributeSet attrs)
      throws XmlPullParserException, IOException {
    int type;

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

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

    int drawableRes = a.getResourceId(com.android.internal.R.styleable.InsetDrawable_drawable, 0);

    int inLeft =
        a.getDimensionPixelOffset(com.android.internal.R.styleable.InsetDrawable_insetLeft, 0);
    int inTop =
        a.getDimensionPixelOffset(com.android.internal.R.styleable.InsetDrawable_insetTop, 0);
    int inRight =
        a.getDimensionPixelOffset(com.android.internal.R.styleable.InsetDrawable_insetRight, 0);
    int inBottom =
        a.getDimensionPixelOffset(com.android.internal.R.styleable.InsetDrawable_insetBottom, 0);

    a.recycle();

    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()
                + ": <inset> tag requires a 'drawable' attribute or "
                + "child tag defining a drawable");
      }
      dr = Drawable.createFromXmlInner(r, parser, attrs);
    }

    if (dr == null) {
      Log.w("drawable", "No drawable specified for <inset>");
    }

    mInsetState.mDrawable = dr;
    mInsetState.mInsetLeft = inLeft;
    mInsetState.mInsetRight = inRight;
    mInsetState.mInsetTop = inTop;
    mInsetState.mInsetBottom = inBottom;

    if (dr != null) {
      dr.setCallback(this);
    }
  }
Exemplo n.º 3
0
  public InsetDrawable(
      Drawable drawable, int insetLeft, int insetTop, int insetRight, int insetBottom) {
    this(null, null);

    mInsetState.mDrawable = drawable;
    mInsetState.mInsetLeft = insetLeft;
    mInsetState.mInsetTop = insetTop;
    mInsetState.mInsetRight = insetRight;
    mInsetState.mInsetBottom = insetBottom;

    if (drawable != null) {
      drawable.setCallback(this);
    }
  }