List of usage examples for android.content.res TypedArray recycle
public void recycle()
From source file:info.papdt.blacklight.support.Utility.java
public static int getLayerColor(Context context) { try {// w ww .ja va 2s. c o m TypedArray array = context.obtainStyledAttributes(R.styleable.BlackLight); int ret = array.getColor(R.styleable.BlackLight_LayerColor, 0); array.recycle(); return ret; } catch (NotFoundException e) { return 0; } }
From source file:info.papdt.blacklight.support.Utility.java
public static int getSelectorGrey(Context context) { try {/*from w ww .j av a 2 s .co m*/ TypedArray array = context.obtainStyledAttributes(R.styleable.BlackLight); int ret = array.getColor(R.styleable.BlackLight_SelectorGrey, 0); array.recycle(); return ret; } catch (NotFoundException e) { return 0; } }
From source file:info.papdt.blacklight.support.Utility.java
public static int getCardSubColor(Context context) { try {//w w w . ja v a2 s . c om TypedArray array = context.obtainStyledAttributes(R.styleable.BlackLight); int ret = array.getColor(R.styleable.BlackLight_CardSubColor, 0); array.recycle(); return ret; } catch (NotFoundException e) { return 0; } }
From source file:info.papdt.blacklight.support.Utility.java
public static int getFABBackground(Context context) { try {/*from w w w . j a v a2 s.c om*/ TypedArray array = context.obtainStyledAttributes(R.styleable.BlackLight); int ret = array.getColor(R.styleable.BlackLight_FABBackground, 0); array.recycle(); return ret; } catch (NotFoundException e) { return 0; } }
From source file:info.papdt.blacklight.support.Utility.java
public static int getDragBackground(Context context) { try {//from w ww .j av a2 s. c o m TypedArray array = context.obtainStyledAttributes(R.styleable.BlackLight); int ret = array.getColor(R.styleable.BlackLight_DragBackground, 0); array.recycle(); return ret; } catch (NotFoundException e) { return 0; } }
From source file:info.papdt.blacklight.support.Utility.java
public static Drawable getFABNewIcon(Context context) { try {// w w w. ja v a2 s . c o m TypedArray array = context.obtainStyledAttributes(R.styleable.BlackLight); Drawable ret = array.getDrawable(R.styleable.BlackLight_FABNewIcon); array.recycle(); return ret; } catch (NotFoundException e) { return null; } }
From source file:info.papdt.blacklight.support.Utility.java
public static int getDrawerForeground(Context context) { try {/* ww w . j a v a2s . c o m*/ TypedArray array = context.obtainStyledAttributes(R.styleable.BlackLight); int ret = array.getColor(R.styleable.BlackLight_DrawerForeground, 0); array.recycle(); return ret; } catch (NotFoundException e) { return 0; } }
From source file:android.support.v7.app.AppCompatViewInflater.java
/** * Allows us to emulate the {@code android:theme} attribute for devices before L. *//* w w w. ja va 2 s .co m*/ private static Context themifyContext(Context context, AttributeSet attrs, boolean useAndroidTheme, boolean useAppTheme) { final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.View, 0, 0); int themeId = 0; if (useAndroidTheme) { // First try reading android:theme if enabled themeId = a.getResourceId(R.styleable.View_android_theme, 0); } if (useAppTheme && themeId == 0) { // ...if that didn't work, try reading app:theme (for legacy reasons) if enabled themeId = a.getResourceId(R.styleable.View_theme, 0); if (themeId != 0) { Log.i(LOG_TAG, "app:theme is now deprecated. " + "Please move to using android:theme instead."); } } a.recycle(); if (themeId != 0 && (!(context instanceof ContextThemeWrapper) || ((ContextThemeWrapper) context).getThemeResId() != themeId)) { // If the context isn't a ContextThemeWrapper, or it is but does not have // the same theme as we need, wrap it in a new wrapper context = new ContextThemeWrapper(context, themeId); } return context; }
From source file:android.support.v7ox.app.AppCompatViewInflater.java
/** * Allows us to emulate the {@code android:theme} attribute for devices before L. *///from w w w.j a va2s .c om private static Context themifyContext(Context context, AttributeSet attrs, boolean useAndroidTheme, boolean useAppTheme) { final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.View, 0, 0); int themeId = 0; if (useAndroidTheme) { // First try reading android:theme if enabled themeId = a.getResourceId(R.styleable.View_android_theme, 0); } if (useAppTheme && themeId == 0) { // ...if that didn't work, try reading app:theme (for legacy reasons) if enabled themeId = a.getResourceId(R.styleable.View_theme_ox, 0); if (themeId != 0) { Log.i(LOG_TAG, "app:theme is now deprecated. " + "Please move to using android:theme instead."); } } a.recycle(); if (themeId != 0 && (!(context instanceof ContextThemeWrapper) || ((ContextThemeWrapper) context).getThemeResId() != themeId)) { // If the context isn't a ContextThemeWrapper, or it is but does not have // the same theme as we need, wrap it in a new wrapper context = new ContextThemeWrapper(context, themeId); } return context; }
From source file:info.papdt.blacklight.support.Utility.java
public static void initDarkTabHost(Activity activity, TabHost tabhost) { if (isDarkMode(activity)) { int textColor = 0; try {/*from w ww . j a v a 2 s . c o m*/ TypedArray array = activity.getTheme().obtainStyledAttributes(R.styleable.BlackLight); textColor = array.getColor(R.styleable.BlackLight_CardForeground, 0); array.recycle(); } catch (NotFoundException e) { return; } for (int i = 0; i < tabhost.getTabWidget().getChildCount(); i++) { TextView tv = (TextView) tabhost.getTabWidget().getChildAt(i).findViewById(android.R.id.title); tv.setTextColor(textColor); } } }