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:de.vanita5.twittnuker.util.ThemeUtils.java

public static Drawable getWindowBackground(final Context context, final int themeRes) {
    final TypedArray a = context.obtainStyledAttributes(null, new int[] { android.R.attr.windowBackground }, 0,
            themeRes);/*from  w w w. ja va  2  s. c  om*/
    final Drawable d = a.getDrawable(0);
    a.recycle();
    if (isTransparentBackground(themeRes)) {
        applyThemeBackgroundAlphaToDrawable(context, d);
    }
    return d;
}

From source file:de.vanita5.twittnuker.util.ThemeUtils.java

public static Drawable getSelectableItemBackgroundDrawable(final Context context) {
    final TypedArray a = context.obtainStyledAttributes(new int[] { android.R.attr.selectableItemBackground });
    try {// www.j  ava2  s.  c om
        return a.getDrawable(0);
    } finally {
        a.recycle();
    }
}

From source file:de.vanita5.twittnuker.util.ThemeUtils.java

public static int getActionBarPopupThemeRes(final Context context) {
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP)
        return 0;
    final TypedArray a = context.obtainStyledAttributes(new int[] { android.R.attr.actionBarPopupTheme });
    try {/* w  ww. ja v a2 s . c o m*/
        return a.getResourceId(0, 0);
    } finally {
        a.recycle();
    }
}

From source file:de.vanita5.twittnuker.util.ThemeUtils.java

public static int getTextColorPrimary(final Context context) {
    final TypedArray a = context.obtainStyledAttributes(new int[] { android.R.attr.textColorPrimary });
    try {//from   w  w  w .jav a2 s  . c  o  m
        return a.getColor(0, Color.TRANSPARENT);
    } finally {
        a.recycle();
    }
}

From source file:com.aaa.activity.main.BaseFragment.java

protected int getActionBarSize() {
    Activity activity = getActivity();/*  w w  w . j a  v  a  2  s  .c  o m*/
    if (activity == null) {
        return 0;
    }
    TypedValue typedValue = new TypedValue();
    int[] textSizeAttr = new int[] { R.attr.actionBarSize };
    int indexOfAttrTextSize = 0;
    TypedArray a = activity.obtainStyledAttributes(typedValue.data, textSizeAttr);
    int actionBarSize = a.getDimensionPixelSize(indexOfAttrTextSize, -1);
    a.recycle();
    return actionBarSize;
}

From source file:de.vanita5.twittnuker.util.ThemeUtils.java

public static int getTextColorSecondary(final Context context) {
    final TypedArray a = context.obtainStyledAttributes(new int[] { android.R.attr.textColorSecondary });
    try {//  w ww . j a va2s . c om
        return a.getColor(0, Color.TRANSPARENT);
    } finally {
        a.recycle();
    }
}

From source file:de.vanita5.twittnuker.util.ThemeUtils.java

@Deprecated
public static Drawable getActionBarBackground(final Context context, final boolean applyAlpha) {
    final TypedArray a = context.obtainStyledAttributes(null, new int[] { android.R.attr.background },
            android.R.attr.actionBarStyle, 0);
    final Drawable d = a.getDrawable(0);
    a.recycle();
    return applyActionBarDrawable(context, d, applyAlpha);
}

From source file:android.support.v7.widget.DividerItemDecoration.java

/**
 * Creates a divider {@link RecyclerView.ItemDecoration} that can be used with a
 * {@link LinearLayoutManager}./*from  ww w  .  ja  v a 2s .c  o m*/
 *
 * @param context Current context, it will be used to access resources.
 * @param orientation Divider orientation. Should be {@link #HORIZONTAL} or {@link #VERTICAL}.
 */
public DividerItemDecoration(Context context, int orientation) {
    final TypedArray a = context.obtainStyledAttributes(ATTRS);
    mDivider = a.getDrawable(0);
    a.recycle();
    setOrientation(orientation);
}

From source file:catchla.yep.adapter.decorator.DividerItemDecoration.java

public DividerItemDecoration(Context context, int orientation) {
    mPadding = new Rect();
    final TypedArray a = context.obtainStyledAttributes(ATTRS);
    mDivider = a.getDrawable(0);/*from www  .j av a  2 s  . co m*/
    a.recycle();
    setOrientation(orientation);
}

From source file:de.vanita5.twittnuker.util.ThemeUtils.java

@Deprecated
public static Drawable getActionBarSplitBackground(final Context context, final boolean applyAlpha) {
    final TypedArray a = context.obtainStyledAttributes(null, new int[] { android.R.attr.backgroundSplit },
            android.R.attr.actionBarStyle, 0);
    final Drawable d = a.getDrawable(0);
    a.recycle();
    return applyActionBarDrawable(context, d, applyAlpha);
}