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 getActionBarBackground(final Context context, final int themeRes) {
    final TypedArray a = context.obtainStyledAttributes(null, new int[] { android.R.attr.background },
            android.R.attr.actionBarStyle, themeRes);
    final Drawable d = a.getDrawable(0);
    a.recycle();
    return applyActionBarDrawable(context, d, isTransparentBackground(themeRes));
}

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

public static int getTextAppearanceLarge(final Context context) {
    // final Context wrapped = getThemedContext(context,
    // getResources(context));
    final TypedArray a = context.obtainStyledAttributes(new int[] { android.R.attr.textAppearanceLarge });
    final int textAppearance = a.getResourceId(0, android.R.style.TextAppearance_Holo_Large);
    a.recycle();
    return textAppearance;
}

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

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

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

public static Drawable getActionBarBackground(final Context context, final int themeRes,
        final int accentColor) {
    if (!isDarkTheme(themeRes)) {
        final ColorDrawable d = new ActionBarColorDrawable(accentColor);
        return applyActionBarDrawable(context, d, isTransparentBackground(themeRes));
    }/*from  ww w  .  j a va2 s.  co  m*/
    final TypedArray a = context.obtainStyledAttributes(null, new int[] { android.R.attr.background },
            android.R.attr.actionBarStyle, themeRes);
    final Drawable d = a.getDrawable(0);
    a.recycle();
    return applyActionBarDrawable(context, d, isTransparentBackground(themeRes));
}

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

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

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

public static Drawable getActionBarStackedBackground(final Context context, final int themeRes) {
    final TypedArray a = context.obtainStyledAttributes(null, new int[] { android.R.attr.backgroundStacked },
            android.R.attr.actionBarStyle, themeRes);
    final Drawable d = a.getDrawable(0);
    a.recycle();
    return applyActionBarDrawable(context, d, isTransparentBackground(themeRes));
}

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

public static int getThemeBackgroundColor(final Context context, int themeRes) {
    if (themeRes == 0) {
        return getThemeBackgroundColor(context);
    }//from  ww w .j  a  v a2s .  c  o m
    final TypedArray a = context.obtainStyledAttributes(null, new int[] { android.R.attr.colorBackground }, 0,
            themeRes);
    try {
        return a.getColor(0, 0);
    } finally {
        a.recycle();
    }
}

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

public static int getThemeColor(final Context context) {
    final Resources res = getResources(context);
    final Context wrapped = getThemedContext(context, res);
    final TypedArray a = wrapped.obtainStyledAttributes(new int[] { android.R.attr.colorActivatedHighlight });
    try {//from  ww  w  . ja  v a 2s  .co m
        return a.getColor(0, res.getColor(R.color.material_light_blue));
    } finally {
        a.recycle();
    }
}

From source file:com.actionbarsherlock.sample.demos.app.ActionBarActionItemCustomView.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuItem item = menu.add(0, android.R.id.copy, 0, "Test");

    final int twentyDp = (int) (20 * getResources().getDisplayMetrics().density);

    TypedArray a = getTheme().obtainStyledAttributes(R.styleable.SherlockTheme);
    final int abHeight = a.getLayoutDimension(R.styleable.SherlockTheme_abHeight, LayoutParams.FILL_PARENT);
    a.recycle();

    LinearLayout l = new LinearLayout(this);
    l.setPadding(twentyDp, 0, twentyDp, 20);
    l.setBackgroundColor(0x55FF0000);/*  w  w w .jav  a2  s.  c  o m*/

    TextView tv = new TextView(this);
    tv.setText("HI!!");
    tv.setGravity(Gravity.CENTER);
    tv.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, abHeight));
    l.addView(tv);

    l.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Toast.makeText(ActionBarActionItemCustomView.this, "Got custom action item click!",
                    Toast.LENGTH_SHORT).show();
        }
    });

    item.setActionView(l);
    item.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);

    return super.onCreateOptionsMenu(menu);
}

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

public ButtonBarLayout(Context context, AttributeSet attrs) {
    super(context, attrs);
    final TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.ButtonBarLayout);
    mAllowStacking = ta.getBoolean(R.styleable.ButtonBarLayout_allowStacking, false);
    ta.recycle();
}