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:androidx.navigation.fragment.NavHostFragment.java

@Override
public void onInflate(Context context, AttributeSet attrs, Bundle savedInstanceState) {
    super.onInflate(context, attrs, savedInstanceState);

    final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.NavHostFragment);
    final int graphId = a.getResourceId(R.styleable.NavHostFragment_navGraph, 0);
    final boolean defaultHost = a.getBoolean(R.styleable.NavHostFragment_defaultNavHost, false);

    if (graphId != 0) {
        setGraph(graphId);//www. j a  va2  s.c om
    }
    if (defaultHost) {
        mDefaultNavHost = true;
    }
    a.recycle();
}

From source file:cn.refactor.ultraindicator.lib.UltraIndicatorView.java

private void init(AttributeSet attrs) {
    TypedArray ta = getContext().obtainStyledAttributes(attrs, R.styleable.UltraIndicatorView);
    mCheckedColor = ta.getColor(R.styleable.UltraIndicatorView_checkedColor, DEFAULT_CHECKED_COLOR);
    mUnCheckedColor = ta.getColor(R.styleable.UltraIndicatorView_uncheckedColor, DEFAULT_UNCHECKED_COLOR);
    mAnimDuration = ta.getInt(R.styleable.UltraIndicatorView_duration, DEFAULT_ANIM_DURATION);
    ta.recycle();

    mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mPaint.setStrokeJoin(Paint.Join.ROUND);
    mPaint.setStrokeCap(Paint.Cap.ROUND);
    mPaint.setStyle(Paint.Style.FILL);
}

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

/**
 * Creates a new animation whose parameters come from the specified context
 * and attributes set./*  w w w. ja  va2s  .c  om*/
 *
 * @param res   The resources
 * @param attrs The set of attributes holding the animation parameters
 * @param anim  Null if this is a ValueAnimator, otherwise this is an
 */
private static ValueAnimator loadAnimator(Context context, Resources res, Theme theme, AttributeSet attrs,
        ValueAnimator anim, float pathErrorScale, XmlPullParser parser) throws NotFoundException {
    TypedArray arrayAnimator = TypedArrayUtils.obtainAttributes(res, theme, attrs,
            AndroidResources.STYLEABLE_ANIMATOR);
    TypedArray arrayObjectAnimator = TypedArrayUtils.obtainAttributes(res, theme, attrs,
            AndroidResources.STYLEABLE_PROPERTY_ANIMATOR);

    if (anim == null) {
        anim = new ValueAnimator();
    }

    parseAnimatorFromTypeArray(anim, arrayAnimator, arrayObjectAnimator, pathErrorScale, parser);

    final int resID = TypedArrayUtils.getNamedResourceId(arrayAnimator, parser, "interpolator",
            AndroidResources.STYLEABLE_ANIMATOR_INTERPOLATOR, 0);
    if (resID > 0) {
        final Interpolator interpolator = AnimationUtilsCompat.loadInterpolator(context, resID);
        anim.setInterpolator(interpolator);
    }

    arrayAnimator.recycle();
    if (arrayObjectAnimator != null) {
        arrayObjectAnimator.recycle();
    }
    return anim;
}

From source file:com.dnielfe.manager.Browser.java

private void setupDrawer() {
    final TypedArray array = obtainStyledAttributes(new int[] { R.attr.themeId });
    final int themeId = array.getInteger(0, SimpleExplorer.THEME_ID_LIGHT);
    array.recycle();

    mDrawer = (LinearLayout) findViewById(R.id.left_drawer);

    // Set shadow of navigation drawer
    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START);

    int icon = themeId == SimpleExplorer.THEME_ID_LIGHT ? R.drawable.holo_light_ic_drawer
            : R.drawable.holo_dark_ic_drawer;

    // Add Navigation Drawer to ActionBar
    mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, icon, R.string.drawer_open,
            R.string.drawer_close) {/* w  w w . j a  v  a 2  s . c om*/

        @Override
        public void onDrawerOpened(View view) {
            super.onDrawerOpened(view);
            mActionBar.setDisplayOptions(
                    ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_HOME_AS_UP | ActionBar.DISPLAY_SHOW_TITLE);
            mActionBar.setTitle(R.string.app_name);
            invalidateOptionsMenu();
        }

        @Override
        public void onDrawerClosed(View view) {
            super.onDrawerClosed(view);
            mActionBar.setDisplayOptions(
                    ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_HOME_AS_UP | ActionBar.DISPLAY_SHOW_CUSTOM);
            invalidateOptionsMenu();
        }
    };

    mDrawerLayout.setDrawerListener(mDrawerToggle);
}

From source file:android.preference.MultiSelectDragListPreference.java

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

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.MultiSelectDragListPreference, 0, 0);
    mEntries = a.getTextArray(R.styleable.MultiSelectDragListPreference_entries);
    mEntryValues = a.getTextArray(R.styleable.MultiSelectDragListPreference_entryValues);
    a.recycle();
}

From source file:arefin.dialogs.core.BaseDialogFragment.java

/**
 * This method resolves the current theme declared in the manifest
 *//*from w w w.ja  v  a2s  .co  m*/
private boolean isActivityThemeLight() {
    try {
        TypedValue val = new TypedValue();

        //Reading attr value from current theme
        getActivity().getTheme().resolveAttribute(R.attr.isLightTheme, val, true);

        //Passing the resource ID to TypedArray to get the attribute value
        TypedArray styledAttributes = getActivity().obtainStyledAttributes(val.data,
                new int[] { R.attr.isLightTheme });
        boolean lightTheme = styledAttributes.getBoolean(0, false);
        styledAttributes.recycle();

        return lightTheme;
    } catch (RuntimeException e) {
        //Resource not found , so sticking to light theme
        return true;
    }
}

From source file:com.actionbarsherlock.internal.widget.ActionBarContainer.java

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

    setBackgroundDrawable(null);/* w w w .  j  a v  a2s  .  c o  m*/

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.SherlockActionBar);
    mBackground = a.getDrawable(R.styleable.SherlockActionBar_background);
    mStackedBackground = a.getDrawable(R.styleable.SherlockActionBar_backgroundStacked);

    if (getId() == R.id.abs__split_action_bar) {
        mIsSplit = true;
        mSplitBackground = a.getDrawable(R.styleable.SherlockActionBar_backgroundSplit);
    }
    a.recycle();

    setWillNotDraw(mIsSplit ? mSplitBackground == null : mBackground == null && mStackedBackground == null);
}

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

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

    TypedArray a = context.obtainStyledAttributes(attrs, Styleable.CHANGE_BOUNDS);
    boolean resizeClip = TypedArrayUtils.getNamedBoolean(a, (XmlResourceParser) attrs, "resizeClip",
            Styleable.ChangeBounds.RESIZE_CLIP, false);
    a.recycle();
    setResizeClip(resizeClip);//w w w.  j  a  va2s .  c om
}

From source file:com.actionbarsherlock.internal.view.menu.ListMenuItemView.java

public ListMenuItemView(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs);
    mContext = context;//from   ww  w . j  av a2 s  . c o m

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.SherlockMenuView, defStyle, 0);

    mBackground = a.getDrawable(R.styleable.SherlockMenuView_itemBackground);
    mTextAppearance = a.getResourceId(R.styleable.SherlockMenuView_itemTextAppearance, -1);
    mPreserveIconSpacing = a.getBoolean(R.styleable.SherlockMenuView_preserveIconSpacing, false);
    mTextAppearanceContext = context;

    a.recycle();
}

From source file:android.support.v7.preference.PreferenceGroup.java

public PreferenceGroup(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
    super(context, attrs, defStyleAttr, defStyleRes);

    mPreferenceList = new ArrayList<>();

    final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.PreferenceGroup, defStyleAttr,
            defStyleRes);//w  w  w  .  ja  v  a2s . c o m

    mOrderingAsAdded = TypedArrayUtils.getBoolean(a, R.styleable.PreferenceGroup_orderingFromXml,
            R.styleable.PreferenceGroup_orderingFromXml, true);

    a.recycle();
}