Example usage for android.content.res TypedArray recycle

List of usage examples for android.content.res TypedArray recycle

Introduction

In this page you can find the example usage for android.content.res TypedArray recycle.

Prototype

public void recycle() 

Source Link

Document

Recycles the TypedArray, to be re-used by a later caller.

Usage

From source file:com.thejoshwa.ultrasonic.androidapp.util.Util.java

public static Drawable getDrawableFromAttribute(Context context, int attr) {
    int[] attrs = new int[] { attr };
    android.content.res.TypedArray ta = context.obtainStyledAttributes(attrs);
    Drawable drawableFromTheme = ta.getDrawable(0);
    ta.recycle();

    return drawableFromTheme;
}

From source file:android.support.v7.internal.widget.AbsActionBarView.java

@Override
protected void onConfigurationChanged(Configuration newConfig) {
    if (Build.VERSION.SDK_INT >= 8) {
        super.onConfigurationChanged(newConfig);
    }/*from   www.  j  a v  a2  s  .c  om*/

    // Action bar can change size on configuration changes.
    // Reread the desired height from the theme-specified style.
    TypedArray a = getContext().obtainStyledAttributes(null, R.styleable.ActionBar, R.attr.actionBarStyle, 0);
    setContentHeight(a.getLayoutDimension(R.styleable.ActionBar_height, 0));
    a.recycle();

    if (mActionMenuPresenter != null) {
        mActionMenuPresenter.onConfigurationChanged(newConfig);
    }
}

From source file:cn.qbcbyb.library.view.PagerTabStrip.java

public PagerTabStrip(Context context, AttributeSet attrs) {
    super(context, attrs);

    setWillNotDraw(false);/*  ww w. ja  v  a2 s . co  m*/

    setOrientation(LinearLayout.HORIZONTAL);

    // get custom attrs

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.PagerTabStrip);

    indicatorDrawable = a.getResourceId(R.styleable.PagerTabStrip_indicatorDrawable,
            R.drawable.pager_indicator);

    a.recycle();

}

From source file:android.support.transition.Slide.java

public Slide(Context context, AttributeSet attrs) {
    super(context, attrs);
    TypedArray a = context.obtainStyledAttributes(attrs, Styleable.SLIDE);
    int edge = TypedArrayUtils.getNamedInt(a, (XmlPullParser) attrs, "slideEdge", Styleable.Slide.SLIDE_EDGE,
            Gravity.BOTTOM);//from ww  w.  ja  va2 s.c om
    a.recycle();
    //noinspection WrongConstant
    setSlideEdge(edge);
}

From source file:android.support.v13.app.FragmentTabHost.java

private void initFragmentTabHost(Context context, AttributeSet attrs) {
    TypedArray a = context.obtainStyledAttributes(attrs, new int[] { android.R.attr.inflatedId }, 0, 0);
    mContainerId = a.getResourceId(0, 0);
    a.recycle();

    super.setOnTabChangedListener(this);

    // If owner hasn't made its own view hierarchy, then as a convenience
    // we will construct a standard one here.
    if (findViewById(android.R.id.tabs) == null) {
        LinearLayout ll = new LinearLayout(context);
        ll.setOrientation(LinearLayout.VERTICAL);
        addView(ll, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
                ViewGroup.LayoutParams.FILL_PARENT));

        TabWidget tw = new TabWidget(context);
        tw.setId(android.R.id.tabs);// www  . ja  v  a2 s . c om
        tw.setOrientation(TabWidget.HORIZONTAL);
        ll.addView(tw, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
                ViewGroup.LayoutParams.WRAP_CONTENT, 0));

        FrameLayout fl = new FrameLayout(context);
        fl.setId(android.R.id.tabcontent);
        ll.addView(fl, new LinearLayout.LayoutParams(0, 0, 0));

        mRealTabContent = fl = new FrameLayout(context);
        mRealTabContent.setId(mContainerId);
        ll.addView(fl, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT, 0, 1));
    }
}

From source file:android.support.graphics.drawable.AnimatorInflaterCompat.java

private static int inferValueTypeOfKeyframe(Resources res, Theme theme, AttributeSet attrs,
        XmlPullParser parser) {//from  w  w  w . j  a v  a 2s  .c  o  m
    int valueType;
    TypedArray a = TypedArrayUtils.obtainAttributes(res, theme, attrs, AndroidResources.STYLEABLE_KEYFRAME);

    TypedValue keyframeValue = TypedArrayUtils.peekNamedValue(a, parser, "value",
            AndroidResources.STYLEABLE_KEYFRAME_VALUE);
    boolean hasValue = (keyframeValue != null);
    // When no value type is provided, check whether it's a color type first.
    // If not, fall back to default value type (i.e. float type).
    if (hasValue && isColorType(keyframeValue.type)) {
        valueType = VALUE_TYPE_COLOR;
    } else {
        valueType = VALUE_TYPE_FLOAT;
    }
    a.recycle();
    return valueType;
}

From source file:cn.bproject.neteasynews.widget.FragmentTabHost.java

private void initFragmentTabHost(Context context, AttributeSet attrs) {
    TypedArray a = context.obtainStyledAttributes(attrs, new int[] { android.R.attr.inflatedId }, 0, 0);
    mContainerId = a.getResourceId(0, 0);
    a.recycle();

    super.setOnTabChangedListener(this);
}

From source file:android.support.v7ox.widget.AbsActionBarView.java

@Override
protected void onConfigurationChanged(Configuration newConfig) {
    if (Build.VERSION.SDK_INT >= 8) {
        super.onConfigurationChanged(newConfig);
    }//from w w w .j a  v  a2  s .  co m

    // Action bar can change size on configuration changes.
    // Reread the desired height from the theme-specified style.
    TypedArray a = getContext().obtainStyledAttributes(null, R.styleable.ActionBar, R.attr.actionBarStyle_ox,
            0);
    setContentHeight(a.getLayoutDimension(R.styleable.ActionBar_height, 0));
    a.recycle();

    if (mActionMenuPresenter != null) {
        mActionMenuPresenter.onConfigurationChanged(newConfig);
    }
}

From source file:android.support.v7.internal.view.ActionBarPolicy.java

public int getTabContainerHeight() {
    TypedArray a = mContext.obtainStyledAttributes(null, R.styleable.ActionBar, R.attr.actionBarStyle, 0);
    int height = a.getLayoutDimension(R.styleable.ActionBar_height, 0);
    Resources r = mContext.getResources();
    if (!hasEmbeddedTabs()) {
        // Stacked tabs; limit the height
        height = Math.min(height, r.getDimensionPixelSize(R.dimen.abc_action_bar_stacked_max_height));
    }//from w  w w  .j ava2s .c om
    a.recycle();
    return height;
}

From source file:cn.thinkjoy.startup.widget.FragmentTabHost.java

private void initFragmentTabHost(Context context, AttributeSet attrs) {
    TypedArray a = context.obtainStyledAttributes(attrs, new int[] { android.R.attr.inflatedId }, 0, 0);
    mContainerId = a.getResourceId(0, 0);
    a.recycle();
    super.setOnTabChangedListener(this);
}