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:cnc.cad.rxjavatestapp.meizi.rx.widget.MultiSwipeRefreshLayout.java

public MultiSwipeRefreshLayout(Context context, AttributeSet attrs) {
    super(context, attrs);
    final TypedArray array = context.obtainStyledAttributes(attrs, R.styleable.MultiSwipeRefreshLayout, 0, 0);

    mForegroundDrawable = array.getDrawable(R.styleable.MultiSwipeRefreshLayout_foreground);
    if (mForegroundDrawable != null) {
        mForegroundDrawable.setCallback(this);
        setWillNotDraw(false);/*from   ww  w . j  a va  2  s.c o m*/
    }
    array.recycle();
}

From source file:android.support.design.internal.SnackbarContentLayout.java

public SnackbarContentLayout(Context context, AttributeSet attrs) {
    super(context, attrs);
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.SnackbarLayout);
    mMaxWidth = a.getDimensionPixelSize(R.styleable.SnackbarLayout_android_maxWidth, -1);
    mMaxInlineActionWidth = a.getDimensionPixelSize(R.styleable.SnackbarLayout_maxActionInlineWidth, -1);
    a.recycle();
}

From source file:alexander.martinz.libs.materialpreferences.MaterialPreference.java

protected void recycleTypedArray(TypedArray typedArray) {
    if (typedArray != null) {
        typedArray.recycle();
    }
}

From source file:github.daneren2005.dsub.util.Util.java

public static int getAttribute(Context context, int attr) {
    int res;/*w w  w  .j  a v  a  2s  .c o  m*/
    int[] attrs = new int[] { attr };
    TypedArray typedArray = context.obtainStyledAttributes(attrs);
    res = typedArray.getResourceId(0, 0);
    typedArray.recycle();
    return res;
}

From source file:com.wellsandwhistles.android.redditsp.reddit.prepared.RedditPreparedMessage.java

public RedditPreparedMessage(final Context context, final RedditMessage message, final long timestamp) {

    this.src = message;

    final int srCommentHeaderBoldCol;
    final int srCommentHeaderAuthorCol;

    {//from   w  w w.  j a va  2 s  . co m
        final TypedArray appearance = context.obtainStyledAttributes(
                new int[] { R.attr.srCommentHeaderBoldCol, R.attr.srCommentHeaderAuthorCol, });

        srCommentHeaderBoldCol = appearance.getColor(0, 255);
        srCommentHeaderAuthorCol = appearance.getColor(1, 255);

        appearance.recycle();
    }

    body = MarkdownParser.parse(message.getUnescapedBodyMarkdown().toCharArray());

    idAndType = message.name;

    final BetterSSB sb = new BetterSSB();

    if (src.author == null) {
        sb.append("[" + context.getString(R.string.general_unknown) + "]",
                BetterSSB.FOREGROUND_COLOR | BetterSSB.BOLD, srCommentHeaderAuthorCol, 0, 1f);
    } else {
        sb.append(src.author, BetterSSB.FOREGROUND_COLOR | BetterSSB.BOLD, srCommentHeaderAuthorCol, 0, 1f);
    }

    sb.append("   ", 0);
    sb.append(SRTime.formatDurationFrom(context, src.created_utc * 1000L),
            BetterSSB.FOREGROUND_COLOR | BetterSSB.BOLD, srCommentHeaderBoldCol, 0, 1f);

    header = sb.get();
}

From source file:mil.nga.giat.mage.help.OpensourceItemFragment.java

private void initView(Context context, AttributeSet attrs) {
    View view = inflate(getContext(), R.layout.fragment_opensource_item, null);

    if (attrs != null) {
        TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.OpensourceItemFragment);
        CharSequence name = a.getText(R.styleable.OpensourceItemFragment_name);
        CharSequence copyright = a.getText(R.styleable.OpensourceItemFragment_copyright);
        CharSequence license = a.getText(R.styleable.OpensourceItemFragment_license);
        a.recycle();

        TextView nameTextView = (TextView) view.findViewById(R.id.opensource_item_name);
        if (StringUtils.isBlank(name)) {
            nameTextView.setVisibility(View.GONE);
        } else {/*  w w  w.ja  v  a 2s. c  om*/
            nameTextView.setText(name);
        }

        TextView copyrightTextView = (TextView) view.findViewById(R.id.opensource_item_copyright);
        if (StringUtils.isBlank(copyright)) {
            copyrightTextView.setVisibility(View.GONE);
        } else {
            copyrightTextView.setText(copyright);
        }

        TextView licenseTextView = (TextView) view.findViewById(R.id.opensource_item_license);
        if (StringUtils.isBlank(license)) {
            licenseTextView.setVisibility(View.GONE);
        } else {
            licenseTextView.setText(license);
        }
    }

    addView(view);
}

From source file:cafe.com.navigationdrawer.NavigationDrawerActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_navigation_drawer);

    mTitle = mDrawerTitle = getTitle();//w w  w  .j a  va2  s  .com

    mMenuNames = getResources().getStringArray(R.array.drawer_items);
    TypedArray typedArray = getResources().obtainTypedArray(R.array.menu_images);
    mMenuImages = new int[typedArray.length()];
    for (int i = 0; i < typedArray.length(); ++i) {
        mMenuImages[i] = typedArray.getResourceId(i, 0);
    }
    typedArray.recycle();
    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    mDrawerList = (ListView) findViewById(R.id.left_drawer);

    // set a custom shadow that overlays the main content when the drawer opens
    //mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START);

    // set up the drawer's list view with items and click listener
    mDrawerList.setAdapter(new ArrayAdapter<String>(this, R.layout.drawer_list_item, mMenuNames));
    mDrawerList.setOnItemClickListener(this);

    // enable ActionBar app icon to behave as action to toggle
    getActionBar().setDisplayHomeAsUpEnabled(true);
    getActionBar().setHomeButtonEnabled(true);

    // ActionBarDrawerToggle ties together the the proper interactions
    // between the sliding drawer and the action bar app icon
    mDrawerToggle = new ActionBarDrawerToggle(this, /* host Activity */
            mDrawerLayout, /* DrawerLayout object */
            R.drawable.ic_drawer, /* nav drawer image to replace 'Up' caret */
            R.string.drawer_open, /* "open drawer" description for accessibility */
            R.string.drawer_close /* "close drawer" description for accessibility */
    ) {
        public void onDrawerClosed(View view) {
            getActionBar().setTitle(mTitle);
        }

        public void onDrawerOpened(View drawerView) {
            getActionBar().setTitle(mDrawerTitle);
        }
    };

    mDrawerLayout.setDrawerListener(mDrawerToggle);

    if (savedInstanceState == null) {
        selectItem(0);
    }
}

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

public Fade(Context context, AttributeSet attrs) {
    super(context, attrs);
    TypedArray a = context.obtainStyledAttributes(attrs, Styleable.FADE);
    @Mode// w  ww . j a  v a 2  s  .  c  o  m
    int fadingMode = TypedArrayUtils.getNamedInt(a, (XmlResourceParser) attrs, "fadingMode",
            Styleable.Fade.FADING_MODE, getMode());
    setMode(fadingMode);
    a.recycle();
}

From source file:androidx.navigation.NavGraph.java

@Override
public void onInflate(@NonNull Context context, @NonNull AttributeSet attrs) {
    super.onInflate(context, attrs);
    TypedArray a = context.getResources().obtainAttributes(attrs, R.styleable.NavGraphNavigator);
    setStartDestination(a.getResourceId(R.styleable.NavGraphNavigator_startDestination, 0));
    a.recycle();
}

From source file:app.philm.in.view.InsetFrameLayout.java

private void init(Context context, AttributeSet attrs, int defStyle) {
    final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.DrawInsetsFrameLayout, defStyle, 0);
    if (a == null) {
        return;/* w w  w . ja  v  a 2  s. co  m*/
    }
    mDefaultInsetBackground = mInsetBackground = a
            .getDrawable(R.styleable.DrawInsetsFrameLayout_insetBackground);
    a.recycle();

    setWillNotDraw(true);
}