TypedArray recycle - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for TypedArray recycle method.

This code example shows how to use the following methods:getBoolean, recycle
This code example shows how to use the following methods:getDimensionPixelSize, getDrawable, getInteger, recycle
This code example shows how to use the following methods:getString, peekValue, recycle
    private static final String INTENT_TAG_NAME = "intent";
 
    private static void parseBundleExtra(Resources resources, String tagName, AttributeSet attrs,
                                         Bundle outBundle) throws XmlPullParserException {
        TypedArray sa = resources.obtainAttributes(attrs, R.styleable.Extra);
        String name = sa.getString(R.styleable.Extra_android_name);
        if (name == null) {
            sa.recycle();
            throw new XmlPullParserException("<" + tagName
                    + "> requires an holo:name attribute at " 
                    + attrs.getPositionDescription());
        } 
        TypedValue v = sa.peekValue(R.styleable.Extra_android_value);
        if (v != null) {
            if (v.type == TypedValue.TYPE_STRING) {
                CharSequence cs = v.coerceToString();
                outBundle.putCharSequence(name, cs);
            } else if (v.type == TypedValue.TYPE_INT_BOOLEAN) {
                outBundle.putBoolean(name, v.data != 0);
            } else if (v.type >= TypedValue.TYPE_FIRST_INT

8
CodeRank
This code example shows how to use the following methods:getBoolean, getIndex, getResourceId, recycle
        mContext=context;
        mVisibilityController = new VisibilityController(this);
        TypedArray a = context.obtainStyledAttributes(attrs, new int[] {
        		android.R.attr.windowTitleStyle,
                android.R.attr.defaultValue });
        mIsLegacy = a.getBoolean(a.getIndex(1 /* defaultValue */), false);
        if (mIsLegacy) {
            mTitleResource = a.getResourceId(a.getIndex(0 /* windowTitleStyle */), 0);
        } else { 
            a.recycle();
            a = context.obtainStyledAttributes(null,
                    new int[] { android.R.attr.titleTextStyle,
                            android.R.attr.subtitleTextStyle },
                    android.R.attr.actionBarStyle,
                    0); 
            mTitleResource = a.getResourceId(a.getIndex(0 /* titleTextStyle */), 0);
            mSubtitleResource = a.getResourceId(a.getIndex(1 /* subtitleTextStyle */), 0);
        } 
        a.recycle();
    } 

8
CodeRank
This code example shows how to use the following methods:getDimensionPixelSize, getDrawable, getInteger, recycle
This code example shows how to use the following methods:getDrawable, recycle
	} 
 
	public ActionBarHomeAsUpIndicator(final Context context, final AttributeSet attrs, final int defStyle) {
		super(context, attrs, defStyle);
		final TypedArray a = context.obtainStyledAttributes(new int[] { android.R.attr.homeAsUpIndicator });
		final Drawable d = a.getDrawable(0);
		a.recycle();
		setImageDrawable(d);
		setScaleType(ScaleType.CENTER);
	} 
 
} 
7
CodeRank
This code example shows how to use the following methods:getResourceId, recycle
 
	public ActionBarSubtitleView(final Context context, final AttributeSet attrs, final int defStyle) {
		super(context, attrs, defStyle);
		final TypedArray a = context.obtainStyledAttributes(null, new int[] { android.R.attr.subtitleTextStyle },
				android.R.attr.actionBarStyle, android.R.style.Widget_Holo_ActionBar);
		final int textAppearance = a.getResourceId(0, android.R.style.Widget_Holo_ActionBar);
		a.recycle();
		setTextAppearance(context, textAppearance);
	} 
 
} 
7
CodeRank
This code example shows how to use the following methods:getBoolean, getIndex, getResourceId, recycle
        mContext=context;
        mVisibilityController = new VisibilityController(this);
        TypedArray a = context.obtainStyledAttributes(attrs, new int[] {
        		android.R.attr.windowTitleStyle,
                android.R.attr.defaultValue });
        mIsLegacy = a.getBoolean(a.getIndex(1 /* defaultValue */), false);
        if (mIsLegacy) {
            mTitleResource = a.getResourceId(a.getIndex(0 /* windowTitleStyle */), 0);
        } else { 
            a.recycle();
            a = context.obtainStyledAttributes(null,
                    new int[] { android.R.attr.titleTextStyle,
                            android.R.attr.subtitleTextStyle },
                    android.R.attr.actionBarStyle,
                    0); 
            mTitleResource = a.getResourceId(a.getIndex(0 /* titleTextStyle */), 0);
            mSubtitleResource = a.getResourceId(a.getIndex(1 /* subtitleTextStyle */), 0);
        } 
        a.recycle();
    } 

8
CodeRank
This code example shows how to use the following methods:getBoolean, recycle
 
    public CapitalizingButton(Context context, AttributeSet attrs) {
        super(context, attrs);
 
        TypedArray a = context.obtainStyledAttributes(attrs, R_styleable_Button);
        mAllCaps = a.getBoolean(R_styleable_Button_textAllCaps, true);
        a.recycle();
    } 
 
    public void setTextCompat(CharSequence text) {
        if (SANS_ICE_CREAM && mAllCaps && text != null) {
            if (IS_GINGERBREAD) {
                try { 
                    setText(text.toString().toUpperCase(Locale.ROOT));
                } catch (NoSuchFieldError e) {
                    //Some manufacturer broke Locale.ROOT. See #572. 
                    setText(text.toString().toUpperCase());
                } 
            } else { 
                setText(text.toString().toUpperCase());
7
CodeRank
This code example shows how to use the following methods:getResourceId, recycle
 
	public ActionBarTitleView(final Context context, final AttributeSet attrs, final int defStyle) {
		super(context, attrs, defStyle);
		final TypedArray a = context.obtainStyledAttributes(null, new int[] { android.R.attr.titleTextStyle },
				android.R.attr.actionBarStyle, android.R.style.Widget_Holo_ActionBar);
		final int textAppearance = a.getResourceId(0, android.R.style.Widget_Holo_ActionBar);
		a.recycle();
		setTextAppearance(context, textAppearance);
	} 
 
} 
7
CodeRank

Related TypedArray recycle Questions & Answers:

Other TypedArray recycle Examples

73:	
74:			// Recycle the typed array
75:			navMenuIcons.recycle();
76:	
77:			mDrawerList.setOnItemClickListener(new SlideMenuClickListener());

Read More

51:	
52:			// Recycle the typed array
53:			navMenuIcons.recycle();
54:	
55:			// setting the nav drawer list adapter

Read More

recycle Method Overview
Give back a previously retrieved array, for later re-use.
See Code Examples for other Android TypedArray Methods: