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:br.com.oficinatablet.chats.decoration.DividerItemDecoration.java

/**
 * Divider padro ser usado//from www . ja  v  a2  s  . com
 */
public DividerItemDecoration(Context context) {
    final TypedArray styledAttributes = context.obtainStyledAttributes(ATTRS);
    mDivider = styledAttributes.getDrawable(0);
    styledAttributes.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 {//w w  w  .j av  a 2s . c o m
        return a.getColor(0, res.getColor(R.color.material_light_blue));
    } finally {
        a.recycle();
    }
}

From source file:ciriti.retrofitmockserver.widget.DividerItemDecoration.java

public DividerItemDecoration(Context context, int orientation) {
    final TypedArray a = context.obtainStyledAttributes(ATTRS);
    mDivider = a.getDrawable(0);//from   ww  w .j a  v  a2s .com
    a.recycle();
    setOrientation(orientation);
}

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

public static int getThemeForegroundColor(final Context context, int theme) {
    final Context wrapped = theme != 0 ? new ContextThemeWrapper(context, theme) : context;
    final TypedArray a = wrapped.obtainStyledAttributes(new int[] { android.R.attr.colorForeground });
    try {/*from w w  w. j  ava 2 s . c om*/
        return a.getColor(0, 0);
    } finally {
        a.recycle();
    }
}

From source file:com.arcao.geocaching4locus.widget.decorator.DividerItemDecoration.java

public DividerItemDecoration(Context context, @Orientation int orientation) {
    final TypedArray a = context.obtainStyledAttributes(ATTRS);
    mDivider = a.getDrawable(0);/*w w w .  j a v  a  2  s  . c om*/
    a.recycle();
    setOrientation(orientation);
}

From source file:cc.solart.turbo.decoration.LinearDividerItemDecoration.java

private void resolveDivider(Context context) {
    final TypedArray a = context.obtainStyledAttributes(ATTRS);
    mDivider = a.getDrawable(0);/*from   w w  w.j  av  a 2  s . c  o  m*/
    a.recycle();
}

From source file:com.ahamed.multiviewadapter.util.SimpleDividerDecoration.java

public SimpleDividerDecoration(Context context, int orientation) {
    final TypedArray a = context.obtainStyledAttributes(ATTRS);
    mDivider = a.getDrawable(0);/*from  w ww .j av a 2 s . c  o  m*/
    a.recycle();
    setOrientation(orientation);
}

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 {/*from ww  w. j  a v a 2  s.  c om*/
        return a.getResourceId(0, 0);
    } finally {
        a.recycle();
    }
}

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();//from  w w w .j  a  v a  2  s .c  o  m
    return textAppearance;
}

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

/**
 * Creates a divider {@link RecyclerView.ItemDecoration} that can be used with a
 * {@link LinearLayoutManager}./*from w  w w.  j ava2 s .  co  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);
}