Search in sources :

Example 51 with TypedArray

use of android.content.res.TypedArray in project platform_frameworks_base by android.

the class NinePatchDrawable method inflate.

@Override
public void inflate(Resources r, XmlPullParser parser, AttributeSet attrs, Theme theme) throws XmlPullParserException, IOException {
    super.inflate(r, parser, attrs, theme);
    final TypedArray a = obtainAttributes(r, theme, attrs, R.styleable.NinePatchDrawable);
    updateStateFromTypedArray(a);
    a.recycle();
    updateLocalState(r);
}
Also used : TypedArray(android.content.res.TypedArray)

Example 52 with TypedArray

use of android.content.res.TypedArray in project platform_frameworks_base by android.

the class NinePatchDrawable method applyTheme.

@Override
public void applyTheme(@NonNull Theme t) {
    super.applyTheme(t);
    final NinePatchState state = mNinePatchState;
    if (state == null) {
        return;
    }
    if (state.mThemeAttrs != null) {
        final TypedArray a = t.resolveAttributes(state.mThemeAttrs, R.styleable.NinePatchDrawable);
        try {
            updateStateFromTypedArray(a);
        } catch (XmlPullParserException e) {
            rethrowAsRuntimeException(e);
        } finally {
            a.recycle();
        }
    }
    if (state.mTint != null && state.mTint.canApplyTheme()) {
        state.mTint = state.mTint.obtainForTheme(t);
    }
    updateLocalState(t.getResources());
}
Also used : TypedArray(android.content.res.TypedArray) XmlPullParserException(org.xmlpull.v1.XmlPullParserException)

Example 53 with TypedArray

use of android.content.res.TypedArray in project platform_frameworks_base by android.

the class GradientDrawable method inflateChildElements.

private void inflateChildElements(Resources r, XmlPullParser parser, AttributeSet attrs, Theme theme) throws XmlPullParserException, IOException {
    TypedArray a;
    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) {
            continue;
        }
        String name = parser.getName();
        if (name.equals("size")) {
            a = obtainAttributes(r, theme, attrs, R.styleable.GradientDrawableSize);
            updateGradientDrawableSize(a);
            a.recycle();
        } else if (name.equals("gradient")) {
            a = obtainAttributes(r, theme, attrs, R.styleable.GradientDrawableGradient);
            updateGradientDrawableGradient(r, a);
            a.recycle();
        } else if (name.equals("solid")) {
            a = obtainAttributes(r, theme, attrs, R.styleable.GradientDrawableSolid);
            updateGradientDrawableSolid(a);
            a.recycle();
        } else if (name.equals("stroke")) {
            a = obtainAttributes(r, theme, attrs, R.styleable.GradientDrawableStroke);
            updateGradientDrawableStroke(a);
            a.recycle();
        } else if (name.equals("corners")) {
            a = obtainAttributes(r, theme, attrs, R.styleable.DrawableCorners);
            updateDrawableCorners(a);
            a.recycle();
        } else if (name.equals("padding")) {
            a = obtainAttributes(r, theme, attrs, R.styleable.GradientDrawablePadding);
            updateGradientDrawablePadding(a);
            a.recycle();
        } else {
            Log.w("drawable", "Bad element under <shape>: " + name);
        }
    }
}
Also used : TypedArray(android.content.res.TypedArray) Paint(android.graphics.Paint)

Example 54 with TypedArray

use of android.content.res.TypedArray in project platform_frameworks_base by android.

the class ShapeDrawable method applyTheme.

@Override
public void applyTheme(Theme t) {
    super.applyTheme(t);
    final ShapeState state = mShapeState;
    if (state == null) {
        return;
    }
    if (state.mThemeAttrs != null) {
        final TypedArray a = t.resolveAttributes(state.mThemeAttrs, R.styleable.ShapeDrawable);
        updateStateFromTypedArray(a);
        a.recycle();
    }
    // Apply theme to contained color state list.
    if (state.mTint != null && state.mTint.canApplyTheme()) {
        state.mTint = state.mTint.obtainForTheme(t);
    }
    // Update local properties.
    updateLocalState(t.getResources());
}
Also used : TypedArray(android.content.res.TypedArray)

Example 55 with TypedArray

use of android.content.res.TypedArray in project platform_frameworks_base by android.

the class StateListDrawable method inflate.

@Override
public void inflate(Resources r, XmlPullParser parser, AttributeSet attrs, Theme theme) throws XmlPullParserException, IOException {
    final TypedArray a = obtainAttributes(r, theme, attrs, R.styleable.StateListDrawable);
    super.inflateWithAttributes(r, parser, a, R.styleable.StateListDrawable_visible);
    updateStateFromTypedArray(a);
    updateDensity(r);
    a.recycle();
    inflateChildElements(r, parser, attrs, theme);
    onStateChange(getState());
}
Also used : TypedArray(android.content.res.TypedArray)

Aggregations

TypedArray (android.content.res.TypedArray)2031 Paint (android.graphics.Paint)193 TypedValue (android.util.TypedValue)190 XmlPullParserException (org.xmlpull.v1.XmlPullParserException)162 Drawable (android.graphics.drawable.Drawable)119 Resources (android.content.res.Resources)118 View (android.view.View)117 Context (android.content.Context)80 XmlResourceParser (android.content.res.XmlResourceParser)80 ColorStateList (android.content.res.ColorStateList)78 AttributeSet (android.util.AttributeSet)78 IOException (java.io.IOException)77 SuppressLint (android.annotation.SuppressLint)66 TextPaint (android.text.TextPaint)63 TextView (android.widget.TextView)63 ViewGroup (android.view.ViewGroup)59 Bundle (android.os.Bundle)48 Point (android.graphics.Point)43 LayoutInflater (android.view.LayoutInflater)42 ImageView (android.widget.ImageView)40