Example usage for android.content Context obtainStyledAttributes

List of usage examples for android.content Context obtainStyledAttributes

Introduction

In this page you can find the example usage for android.content Context obtainStyledAttributes.

Prototype

public final TypedArray obtainStyledAttributes(@StyleableRes int[] attrs) 

Source Link

Document

Retrieve styled attribute information in this Context's theme.

Usage

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

public static int getCardBackgroundColor(final Context context) {
    final TypedArray a = context.obtainStyledAttributes(new int[] { R.attr.cardItemBackgroundColor });
    final int color = a.getColor(0, Color.TRANSPARENT);
    a.recycle();/* w w  w. j  a  v  a 2  s. com*/
    final int themeAlpha = getThemeAlpha(context);
    return themeAlpha << 24 | (0x00FFFFFF & color);
}

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 {//from   w  w w. j a va2  s  .c om
        return a.getDrawable(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 {//w ww .ja  v a  2 s . com
        return a.getColor(0, Color.TRANSPARENT);
    } finally {
        a.recycle();
    }
}

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 {/*ww w  .ja  v  a 2s. com*/
        return a.getColor(0, Color.TRANSPARENT);
    } finally {
        a.recycle();
    }
}

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

public static int getThemeBackgroundColor(final Context context) {
    final TypedArray a = context.obtainStyledAttributes(new int[] { android.R.attr.colorBackground });
    try {//from ww w  . java  2s. com
        return a.getColor(0, 0);
    } finally {
        a.recycle();
    }
}

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

public static boolean isFloatingWindow(final Context context) {

    final TypedArray a = context.obtainStyledAttributes(new int[] { android.R.attr.windowIsFloating });
    final boolean b = a.getBoolean(0, false);
    a.recycle();//from   w  w  w .ja v a 2s  .  c o m
    return b;
}

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

public static Drawable getWindowBackground(final Context context) {
    final TypedArray a = context.obtainStyledAttributes(new int[] { android.R.attr.windowBackground });
    final Drawable d = a.getDrawable(0);
    a.recycle();//www.j  a  va2s  .  c o  m
    if (isTransparentBackground(context)) {
        applyThemeBackgroundAlphaToDrawable(context, d);
    }
    return d;
}

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

public static Context getActionBarContext(final Context context) {
    final TypedArray a = context.obtainStyledAttributes(
            new int[] { android.R.attr.actionBarTheme, android.R.attr.actionBarWidgetTheme });
    final int resId;
    try {/*from w w w . j  a  va 2  s  . c  o  m*/
        resId = a.hasValue(0) ? a.getResourceId(0, 0) : a.getResourceId(1, 0);
    } finally {
        a.recycle();
    }
    if (resId == 0)
        return context;
    return new ContextThemeWrapper(context, resId);
}

From source file:com.ahamed.sample.common.decorator.ThickItemDecorator.java

public ThickItemDecorator(Context context) {
    final TypedArray a = context.obtainStyledAttributes(ATTRS);
    mDivider = a.getDrawable(0);
    a.recycle();
}

From source file:android.tumb.com.tumb.Misc.DividerItemDecoration.java

public DividerItemDecoration(Context context) {
    final TypedArray styledAttributes = context.obtainStyledAttributes(ATTRS);
    mDivider = ContextCompat.getDrawable(context, R.drawable.question_recycler_decorator);
    styledAttributes.recycle();/*from   w w  w  .ja  v  a  2s . c  om*/
}