Search in sources :

Example 41 with TypedArray

use of android.content.res.TypedArray in project GreenDroid by cyrilmottier.

the class ProgressItem method inflate.

@Override
public void inflate(Resources r, XmlPullParser parser, AttributeSet attrs) throws XmlPullParserException, IOException {
    super.inflate(r, parser, attrs);
    TypedArray a = r.obtainAttributes(attrs, R.styleable.ProgressItem);
    isInProgress = a.getBoolean(R.styleable.ProgressItem_isInProgress, DEFAULT_IS_IN_PROGRESS);
    a.recycle();
}
Also used : TypedArray(android.content.res.TypedArray)

Example 42 with TypedArray

use of android.content.res.TypedArray in project GreenDroid by cyrilmottier.

the class TextItem method inflate.

@Override
public void inflate(Resources r, XmlPullParser parser, AttributeSet attrs) throws XmlPullParserException, IOException {
    super.inflate(r, parser, attrs);
    TypedArray a = r.obtainAttributes(attrs, R.styleable.TextItem);
    text = a.getString(R.styleable.TextItem_text);
    a.recycle();
}
Also used : TypedArray(android.content.res.TypedArray)

Example 43 with TypedArray

use of android.content.res.TypedArray in project GreenDroid by cyrilmottier.

the class ThumbnailItem method inflate.

@Override
public void inflate(Resources r, XmlPullParser parser, AttributeSet attrs) throws XmlPullParserException, IOException {
    super.inflate(r, parser, attrs);
    TypedArray a = r.obtainAttributes(attrs, R.styleable.ThumbnailItem);
    drawableId = a.getResourceId(R.styleable.ThumbnailItem_thumbnail, drawableId);
    drawableURL = a.getString(R.styleable.ThumbnailItem_thumbnailURL);
    a.recycle();
}
Also used : TypedArray(android.content.res.TypedArray)

Example 44 with TypedArray

use of android.content.res.TypedArray in project CustomFontLib by daniribalbert.

the class CustomFontUtils method getTypeFace.

public static Typeface getTypeFace(final TextView v, final AttributeSet attrs) {
    final TypedArray tArray = v.getContext().getTheme().obtainStyledAttributes(attrs, R.styleable.customFont, 0, 0);
    String fontName = "";
    try {
        fontName = tArray.getString(R.styleable.customFont_font);
    } finally {
        tArray.recycle();
    }
    if (!TextUtils.isEmpty(fontName)) {
        final int style;
        final Typeface typeface = v.getTypeface();
        if (typeface == null) {
            style = Typeface.NORMAL;
        } else {
            style = typeface.getStyle();
        }
        String mFontName = getFontFile(v.getContext(), fontName, style);
        if (sTypefaceMap.containsKey(mFontName)) {
            return sTypefaceMap.get(mFontName);
        }
        Typeface newTypeface = typeface;
        if (!TextUtils.isEmpty(mFontName)) {
            try {
                newTypeface = Typeface.createFromAsset(v.getContext().getAssets(), FONTS_DIR + "/" + mFontName);
            } catch (Exception e) {
                newTypeface = typeface;
            }
        }
        sTypefaceMap.put(mFontName, newTypeface);
        return newTypeface;
    }
    return null;
}
Also used : Typeface(android.graphics.Typeface) TypedArray(android.content.res.TypedArray)

Example 45 with TypedArray

use of android.content.res.TypedArray in project FlexibleAdapter by davideas.

the class Utils method getColorAccent.

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public static int getColorAccent(Context context) {
    if (colorAccent < 0) {
        int accentAttr = eu.davidea.flexibleadapter.utils.Utils.hasLollipop() ? android.R.attr.colorAccent : R.attr.colorAccent;
        TypedArray androidAttr = context.getTheme().obtainStyledAttributes(new int[] { accentAttr });
        //Default: material_deep_teal_500
        colorAccent = androidAttr.getColor(0, 0xFF009688);
        androidAttr.recycle();
    }
    return colorAccent;
}
Also used : TypedArray(android.content.res.TypedArray) Point(android.graphics.Point) TargetApi(android.annotation.TargetApi)

Aggregations

TypedArray (android.content.res.TypedArray)1991 Paint (android.graphics.Paint)190 TypedValue (android.util.TypedValue)185 XmlPullParserException (org.xmlpull.v1.XmlPullParserException)162 Resources (android.content.res.Resources)118 View (android.view.View)116 Drawable (android.graphics.drawable.Drawable)114 XmlResourceParser (android.content.res.XmlResourceParser)80 Context (android.content.Context)78 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)62 ViewGroup (android.view.ViewGroup)59 Bundle (android.os.Bundle)48 LayoutInflater (android.view.LayoutInflater)42 Point (android.graphics.Point)41 ImageView (android.widget.ImageView)40