List of usage examples for android.content Context getColor
@ColorInt public final int getColor(@ColorRes int id)
From source file:Main.java
public static int getColor(Context context, int colorResId) { int color;/* ww w . ja v a 2 s .c om*/ if (SDK_INT >= M) { color = context.getColor(colorResId); } else { color = context.getResources().getColor(colorResId); } return color; }
From source file:Main.java
public static int retrieverColor(Context context, int color) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { return context.getColor(color); } else {// w w w . j ava2 s . c o m return context.getResources().getColor(color); } }
From source file:Main.java
public static int getColorWrapper(Context context, int id) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { return context.getColor(id); } else {//from w w w .jav a 2s . c om //noinspection deprecation return context.getResources().getColor(id); } }
From source file:Main.java
static public int getColor(Context context, int resourceId) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { return context.getColor(resourceId); } else {/*from w w w . j a v a 2s . c o m*/ //noinspection deprecation return context.getResources().getColor(resourceId); } }
From source file:Main.java
@SuppressWarnings("deprecation") public static int getColor(@NonNull Context context, int colorId) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { return context.getColor(colorId); }// www.ja v a 2 s .c o m return context.getResources().getColor(colorId); }
From source file:Main.java
public static int getColor(Context context, @ColorRes int colorRes) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { return context.getColor(colorRes); } else {/*from w w w .ja v a2 s .c o m*/ //noinspection deprecation return context.getResources().getColor(colorRes); } }
From source file:Main.java
public static int getColour(Context context, int resId) { if (context == null) return 0; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) return context.getColor(resId); return context.getResources().getColor(resId); }
From source file:Main.java
/** * Returns a color associated with a particular resource ID * <p/>/*from ww w. j a va2 s .com*/ * Starting in {@link Build.VERSION_CODES#M}, the returned * color will be styled for the specified Context's theme. * * @param colorId The desired resource identifier, as generated by the aapt * tool. This integer encodes the package, type, and resource * entry. The value 0 is an invalid identifier. * @return A single color value in the form 0xAARRGGBB. */ public static int getColor(Context context, @ColorRes int colorId) { if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.LOLLIPOP_MR1) { //noinspection deprecation return context.getResources().getColor(colorId); } else { return context.getColor(colorId); } }
From source file:com.flexible.flexibleadapter.utils.DrawableUtils.java
/** * Helper to get the system default Color Control Highlight. Returns the color of the * {@code R.attr.colorControlHighlight} attribute in the overridden style. * * @param context the context/*from w w w . j a va 2 s .c o m*/ * @return Default Color Control Highlight * @since 5.0.0-b7 Created, returns the resourceId * <br/> 5.0.0-rc1 Now returns the real color (not the resourceId) */ @ColorInt public static int getColorControlHighlight(Context context) { TypedValue outValue = new TypedValue(); // It's important to not use the android.R because this wouldn't add the overridden drawable context.getTheme().resolveAttribute(R.attr.colorControlHighlight, outValue, true); if (Utils.hasMarshmallow()) return context.getColor(outValue.resourceId); else return context.getResources().getColor(outValue.resourceId); }
From source file:io.romain.passport.utils.glide.CityItemTarget.java
@SuppressWarnings("deprecation") @ColorInt// w w w .j a v a 2 s. co m private int getColor(Context context, @ColorRes int res) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { return context.getColor(res); } else { return context.getResources().getColor(res); } }