Java Code Examples for android.support.annotation.AttrRes

The following are top voted examples for showing how to use android.support.annotation.AttrRes. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: searchablespinner   File: SearchableSpinner.java   View source code 7 votes vote down vote up
public SearchableSpinner(@NonNull Context context, @Nullable AttributeSet attrs, @AttrRes int defStyleAttr, @StyleRes int defStyleRes) {
    super(context, attrs, defStyleAttr, defStyleRes);
    mContext = context;
    getAttributeSet(attrs, defStyleAttr, defStyleRes);

    final LayoutInflater factory = LayoutInflater.from(context);
    factory.inflate(R.layout.view_searchable_spinner, this, true);

    mSpinnerListContainer = (LinearLayout) factory.inflate(R.layout.view_list, this, false);
    mSpinnerListView = (ListView) mSpinnerListContainer.findViewById(R.id.LstVw_SpinnerListView);
    if (mListItemDivider != null) {
        mSpinnerListView.setDivider(mListItemDivider);
        mSpinnerListView.setDividerHeight(mListDividerSize);
    }
    mEmptyTextView = (TextView) mSpinnerListContainer.findViewById(R.id.TxtVw_EmptyText);
    mSpinnerListView.setEmptyView(mEmptyTextView);
}
 
Example 2
Project: q-mail   File: SecurityInfoDialog.java   View source code 6 votes vote down vote up
private void setCryptoMessageSingleLine(@AttrRes int colorAttr,
        @StringRes int topTextRes, @DrawableRes int statusIconRes,
        @DrawableRes Integer statusDotsRes) {
    @ColorInt int color = ThemeUtils.getStyledColor(getActivity(), colorAttr);

    authenticationIcon_1.setImageResource(statusIconRes);
    authenticationIcon_1.setColorFilter(color);
    authenticationText.setText(topTextRes);

    if (statusDotsRes != null) {
        authenticationIcon_3.setImageResource(statusDotsRes);
        authenticationIcon_3.setColorFilter(color);
        authenticationIcon_3.setVisibility(View.VISIBLE);
    } else {
        authenticationIcon_3.setVisibility(View.GONE);
    }

    trustText.setVisibility(View.GONE);
    trustIconFrame.setVisibility(View.GONE);
}
 
Example 3
Project: searchablespinner   File: SearchableSpinner.java   View source code 6 votes vote down vote up
private void getAttributeSet(@Nullable AttributeSet attrs, @AttrRes int defStyleAttr, @StyleRes int defStyleRes) {
    if (attrs != null) {
        try {
            TypedArray attributes = mContext.getTheme().obtainStyledAttributes(attrs, R.styleable.SearchableSpinner, defStyleAttr, defStyleRes);
            mRevealViewBackgroundColor = attributes.getColor(R.styleable.SearchableSpinner_RevealViewBackgroundColor, Color.WHITE);
            mStartEditTintColor = attributes.getColor(R.styleable.SearchableSpinner_StartSearchTintColor, Color.GRAY);
            mEditViewBackgroundColor = attributes.getColor(R.styleable.SearchableSpinner_SearchViewBackgroundColor, Color.WHITE);
            mEditViewTextColor = attributes.getColor(R.styleable.SearchableSpinner_SearchViewTextColor, Color.BLACK);
            mDoneEditTintColor = attributes.getColor(R.styleable.SearchableSpinner_DoneSearchTintColor, Color.GRAY);
            mBordersSize = attributes.getDimensionPixelSize(R.styleable.SearchableSpinner_BordersSize, 4);
            mExpandSize = attributes.getDimensionPixelSize(R.styleable.SearchableSpinner_SpinnerExpandHeight, 0);
            mShowBorders = attributes.getBoolean(R.styleable.SearchableSpinner_ShowBorders, false);
            mBoarderColor = attributes.getColor(R.styleable.SearchableSpinner_BoarderColor, Color.GRAY);
            mAnimDuration = attributes.getColor(R.styleable.SearchableSpinner_AnimDuration, DefaultAnimationDuration);
            mKeepLastSearch = attributes.getBoolean(R.styleable.SearchableSpinner_KeepLastSearch, false);
            mRevealEmptyText = attributes.getString(R.styleable.SearchableSpinner_RevealEmptyText);
            mSearchHintText = attributes.getString(R.styleable.SearchableSpinner_SearchHintText);
            mNoItemsFoundText = attributes.getString(R.styleable.SearchableSpinner_NoItemsFoundText);
            mListItemDivider = attributes.getDrawable(R.styleable.SearchableSpinner_ItemsDivider);
            mListDividerSize = attributes.getDimensionPixelSize(R.styleable.SearchableSpinner_DividerHeight, 0);
        } catch (UnsupportedOperationException e) {
            Log.e("SearchableSpinner", "getAttributeSet --> " + e.getLocalizedMessage());
        }
    }
}
 
Example 4
Project: IslamicLibraryAndroid   File: Util.java   View source code 5 votes vote down vote up
public static ColorStateList resolveColorStateList(Context context, @AttrRes int attr) {
    TEMP_ARRAY[0] = attr;
    TintTypedArray ta = TintTypedArray.obtainStyledAttributes(context, null, TEMP_ARRAY);
    try {
        return ta.getColorStateList(0);
    } finally {
        ta.recycle();
    }
}
 
Example 5
Project: IslamicLibraryAndroid   File: Util.java   View source code 5 votes vote down vote up
public static int resolveResourceId(Context context, @AttrRes int attr, int fallback) {
    TEMP_ARRAY[0] = attr;
    TypedArray ta = context.obtainStyledAttributes(TEMP_ARRAY);
    try {
        return ta.getResourceId(0, fallback);
    } finally {
        ta.recycle();
    }
}
 
Example 6
Project: StyleableToast   File: Utils.java   View source code 5 votes vote down vote up
public static boolean getStyleValuesBoolean(Context context, @AttrRes int attrId, int style) {
    TypedArray a = null;

    if (style > 0) {
        int[] AttrSet = {attrId};
        a = context.obtainStyledAttributes(style, AttrSet);
        a.recycle();
    }
    return a.getBoolean(0, false);
}
 
Example 7
Project: q-mail   File: SecurityInfoDialog.java   View source code 5 votes vote down vote up
private void setTransportSecurityMessageSingleLine(@AttrRes int colorAttr,
        @StringRes int topTextRes, @DrawableRes int statusIconRes) {
    @ColorInt int color = ThemeUtils.getStyledColor(getActivity(), colorAttr);

    transportSecurityIcon_1.setImageResource(statusIconRes);
    transportSecurityIcon_1.setColorFilter(color);
    transportSecurityText.setText(topTextRes);
}
 
Example 8
Project: ChromeLikeTabSwitcher   File: ThemeHelper.java   View source code 5 votes vote down vote up
/**
 * Returns the drawable, which corresponds to a specific theme attribute, regarding the
 * theme, which is used when using a specific layout.
 *
 * @param layout
 *         The layout as a value of the enum {@link Layout}. The layout may not be null
 * @param resourceId
 *         The resource id of the theme attribute, the drawable should be obtained from, as an
 *         {@link Integer} value. The resource id must correspond to a valid theme attribute
 * @return The color state list, which has been obtained, as an instance of the class {@link
 * ColorStateList}
 */
public Drawable getDrawable(@NonNull final Layout layout, @AttrRes final int resourceId) {
    try {
        return ThemeUtil.getDrawable(context, resourceId);
    } catch (NotFoundException e1) {
        int themeResourceId = getThemeResourceId(layout);

        try {
            return ThemeUtil.getDrawable(context, themeResourceId, resourceId);
        } catch (NotFoundException e) {
            themeResourceId = obtainThemeFromThemeAttributes(layout, themeResourceId);
            return ThemeUtil.getDrawable(context, themeResourceId, resourceId);
        }
    }
}
 
Example 9
Project: q-mail   File: SecurityInfoDialog.java   View source code 5 votes vote down vote up
private void setDKIMMessageSingleLine(@AttrRes int colorAttr,
        @StringRes int topTextRes, @DrawableRes int statusIconRes) {
    @ColorInt int color = ThemeUtils.getStyledColor(getActivity(), colorAttr);

    dkimIcon_1.setImageResource(statusIconRes);
    dkimIcon_1.setColorFilter(color);
    dkimText.setText(topTextRes);
}
 
Example 10
Project: Mire   File: Preferences.java   View source code 5 votes vote down vote up
@ColorInt
   public static int getAttributeColor(Context context, @AttrRes int attr, int fallback) 
{
       TypedArray a = context.getTheme().obtainStyledAttributes(new int[] {attr});
       try 
	{
           return a.getColor(0, fallback);
       }
	finally 
	{
           a.recycle();
       }
   }
 
Example 11
Project: MaterialStepperView   File: ViewUtils.java   View source code 5 votes vote down vote up
/**
 * Get color attribute from current theme
 *
 * @param context Themed context
 * @param attr The resource id of color attribute
 * @return Result
 */
@ColorInt
static int getColorFromAttr(Context context, @AttrRes int attr) {
	TypedArray array = context.getTheme().obtainStyledAttributes(new int[]{attr});
	int color = array.getColor(0, Color.TRANSPARENT);
	array.recycle();
	return color;
}
 
Example 12
Project: GitHub   File: DialogUtils.java   View source code 5 votes vote down vote up
private static Drawable resolveDrawable(Context context,
                                        @AttrRes int attr,
                                        @SuppressWarnings(
                                                "SameParameterValue") Drawable fallback) {
    TypedArray a = context.getTheme().obtainStyledAttributes(new int[]{attr});
    try {
        Drawable d = a.getDrawable(0);
        if (d == null && fallback != null)
            d = fallback;
        return d;
    } finally {
        a.recycle();
    }
}
 
Example 13
Project: CookieBar2   File: ThemeResolver.java   View source code 5 votes vote down vote up
static int getColor(Context context, @AttrRes int attr, int defaultColor) {
    TypedArray a = context.getTheme().obtainStyledAttributes(new int[]{attr});
    try {
        return a.getColor(0, defaultColor);
    } finally {
        a.recycle();
    }
}
 
Example 14
Project: SCCameraView   File: SCCameraView.java   View source code 5 votes vote down vote up
public SCCameraView(@NonNull Context context, @Nullable AttributeSet attrs, @AttrRes int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    if (isInEditMode()){
        cameraView = null;
        return;
    }

    cameraView = BaseCameraView.createCameraView(context);
    cameraView.loadAspectRatios();
    this.addView(cameraView);
}
 
Example 15
Project: Mix   File: ThemeUtils.java   View source code 5 votes vote down vote up
public static boolean getThemeAttrBoolean(Context context, @AttrRes int attr) {
    TEMP_ARRAY[0] = attr;
    TypedArray a = context.obtainStyledAttributes(null, TEMP_ARRAY);
    try {
        return a.getBoolean(0, false);
    } finally {
        a.recycle();
    }
}
 
Example 16
Project: MzViewPager   File: MzViewPager.java   View source code 5 votes vote down vote up
public MzViewPager(@NonNull Context context, @Nullable AttributeSet attrs, @AttrRes int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    handleTypedArray(context, attrs);

    mVpMargin = dp2px(DEFAULT_VP_MARGIN);
    mVpPadding = dp2px(DEFAULT_VP_PADDING);

    mContext = context;
    initViewPager();
}
 
Example 17
Project: BlackList   File: Notifications.java   View source code 5 votes vote down vote up
private static int getColor(Context context, @AttrRes int attrRes) {
    int styleRes = R.style.AppTheme_Dark;
    if (Settings.getBooleanValue(context, Settings.UI_THEME_DARK)) {
        styleRes = R.style.AppTheme_Light;
    }
    int colorRes = Utils.getResourceId(context, attrRes, styleRes);
    return ContextCompat.getColor(context, colorRes);
}
 
Example 18
Project: Aequorea   File: ACheckBox.java   View source code 5 votes vote down vote up
public ACheckBox(@NonNull Context context, @Nullable AttributeSet attrs, @AttrRes int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    
    View.inflate(context, R.layout.layout_custom_checkbox, this);
    init(context, attrs);
    setOnClickListener(this);
}
 
Example 19
Project: Pocket-Plays-for-Twitch   File: Service.java   View source code 5 votes vote down vote up
/**
 * Finds and returns an attribute color. If it was not found the method returns the default color
 */
public static int getColorAttribute(@AttrRes int attribute, @ColorRes int defaultColor, Context context) {
	TypedValue a = new TypedValue();
	context.getTheme().resolveAttribute(attribute, a, true);
	if (a.type >= TypedValue.TYPE_FIRST_COLOR_INT && a.type <= TypedValue.TYPE_LAST_COLOR_INT) {
		return a.data;
	} else {
		return ContextCompat.getColor(context, defaultColor);
	}
}
 
Example 20
Project: FancyAccordionView   File: ThemeUtils.java   View source code 5 votes vote down vote up
/**
 * Convenience method for retrieving a themed drawable.
 *
 * @param context the {@link Context} to resolve the theme attribute against
 * @param attr    the attribute corresponding to the drawable to resolve
 * @return the drawable of the resolved attribute
 */
public static Drawable resolveDrawable(Context context, @AttrRes int attr) {
    final TypedArray a;
    synchronized (TEMP_ATTR) {
        TEMP_ATTR[0] = attr;
        a = context.obtainStyledAttributes(TEMP_ATTR);
    }

    try {
        return a.getDrawable(0);
    } finally {
        a.recycle();
    }
}
 
Example 21
Project: microMathematics   File: CompatUtils.java   View source code 5 votes vote down vote up
/**
 * Procedure sets the background for given view as a drawable with given resource id
 */
@SuppressWarnings("deprecation")
public static void updateBackgroundAttr(Context c, View v, @DrawableRes int drawableId, @AttrRes int colorAttrId)
{
    Drawable bg = null;

    if (drawableId >= 0)
    {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
        {
            bg = c.getResources().getDrawable(drawableId, c.getTheme());
        }
        else
        {
            bg = c.getResources().getDrawable(drawableId);
        }
    }

    setDrawableColorAttr(c, bg, colorAttrId);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN)
    {
        v.setBackground(bg);
    }
    else
    {
        v.setBackgroundDrawable(bg);
    }
}
 
Example 22
Project: Mix   File: ThemeUtils.java   View source code 5 votes vote down vote up
public static int getThemeAttrId(Context context, @AttrRes int attr) {
    TEMP_ARRAY[0] = attr;
    TypedArray a = context.obtainStyledAttributes(null, TEMP_ARRAY);
    try {
        return a.getResourceId(0, 0);
    } finally {
        a.recycle();
    }
}
 
Example 23
Project: Tusky   File: ComposeActivity.java   View source code 5 votes vote down vote up
private void updateHideMediaToggleColor() {
    @AttrRes int attribute;
    if (statusMarkSensitive) {
        attribute = R.attr.compose_hide_media_button_selected_color;
    } else {
        attribute = R.attr.compose_hide_media_button_color;
    }
    ThemeUtils.setDrawableTint(this, hideMediaToggle.getDrawable(), attribute);
}
 
Example 24
Project: NetworkStateView   File: NetworkStateView.java   View source code 5 votes vote down vote up
public NetworkStateView(@NonNull Context context, @Nullable AttributeSet attrs, @AttrRes int defStyleAttr) {
    super(context, attrs, defStyleAttr);

    TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.NetworkStateView, defStyleAttr, R.style.NetworkStateView_Style);

    mLoadingViewId = typedArray.getResourceId(R.styleable.NetworkStateView_loadingView, R.layout.view_loading);

    mErrorViewId = typedArray.getResourceId(R.styleable.NetworkStateView_errorView, R.layout.view_network_error);
    mErrorImageId = typedArray.getResourceId(R.styleable.NetworkStateView_nsvErrorImage, NO_ID);
    mErrorText = typedArray.getString(R.styleable.NetworkStateView_nsvErrorText);

    mNoNetworkViewId = typedArray.getResourceId(R.styleable.NetworkStateView_noNetworkView, R.layout.view_no_network);
    mNoNetworkImageId = typedArray.getResourceId(R.styleable.NetworkStateView_nsvNoNetworkImage, NO_ID);
    mNoNetworkText = typedArray.getString(R.styleable.NetworkStateView_nsvNoNetworkText);

    mEmptyViewId = typedArray.getResourceId(R.styleable.NetworkStateView_emptyView, R.layout.view_empty);
    mEmptyImageId = typedArray.getResourceId(R.styleable.NetworkStateView_nsvEmptyImage, NO_ID);
    mEmptyText = typedArray.getString(R.styleable.NetworkStateView_nsvEmptyText);

    mRefreshViewId = typedArray.getResourceId(R.styleable.NetworkStateView_nsvRefreshImage, NO_ID);

    mTextColor = typedArray.getColor(R.styleable.NetworkStateView_nsvTextColor, 0x8a000000);
    mTextSize = typedArray.getDimensionPixelSize(R.styleable.NetworkStateView_nsvTextSize, UIUtils.dp2px(14));

    typedArray.recycle();

    mInflater = LayoutInflater.from(context);
    params = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
    setBackgroundColor(UIUtils.getColor(R.color.white));
}
 
Example 25
Project: AndelaTrackChallenge   File: ThemeUtils.java   View source code 5 votes vote down vote up
public static int getThemeAttrColor(@NonNull Context context, @AttrRes int attributeColor) {
    int[] attrs = new int[]{attributeColor};
    TypedArray ta = context.obtainStyledAttributes(attrs);
    int color = ta.getColor(0, Color.TRANSPARENT);
    ta.recycle();
    return color;
}
 
Example 26
Project: android_ui   File: PullController.java   View source code 5 votes vote down vote up
/**
 * Performs configuration of this controller from the given <var>attrs</var>.
 *
 * @param context      Context used to obtain values for the given attributes.
 * @param attrs        Set of attributes with values to be used to set up this controller.
 * @param defStyleAttr An attribute which contains a reference to a default style resource, for
 *                     the view attached to this controller, within a theme of the given context.
 * @param defStyleRes  Resource id of the default style for the view attached to this controller.
 * @return {@code True} if some setting of this controller has been changed, {@code false} otherwise.
 */
@SuppressWarnings("ResourceType")
public boolean setUpFromAttrs(@NonNull Context context, AttributeSet attrs, @AttrRes int defStyleAttr, @StyleRes int defStyleRes) {
	final TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.Ui_PullController, defStyleAttr, defStyleRes);
	if (typedArray != null) {
		this.ensurePullHelper();
		final int n = typedArray.getIndexCount();
		for (int i = 0; i < n; i++) {
			final int index = typedArray.getIndex(i);
			if (index == R.styleable.Ui_PullController_uiPullMode) {
				setPullMode(typedArray.getInteger(index, mPullHelper.getPullMode()));
			} else if (index == R.styleable.Ui_PullController_uiPullMinVelocity) {
				setPullMinVelocity(typedArray.getFloat(index, getPullMinVelocity()));
			} else if (index == R.styleable.Ui_PullController_uiPullDistanceFraction) {
				setPullDistanceFraction(typedArray.getFloat(index, getPullDistanceFraction()));
			} else if (index == R.styleable.Ui_PullController_uiPullDistance) {
				setPullDistance(typedArray.getDimensionPixelSize(index, (int) getPullDistance()));
			} else if (index == R.styleable.Ui_PullController_uiPullCollapseDuration) {
				setPullCollapseDuration(typedArray.getInt(index, (int) mAnimations.pullCollapseDuration));
			} else if (index == R.styleable.Ui_PullController_uiPullCollapseDelay) {
				setPullCollapseDelay(typedArray.getInt(index, (int) mAnimations.pullCollapseDelay));
			}
		}
		typedArray.recycle();
		return n > 0;
	}
	return false;
}
 
Example 27
Project: Tusky   File: ThemeUtils.java   View source code 5 votes vote down vote up
public static @DrawableRes int getDrawableId(Context context, @AttrRes int attribute,
        @DrawableRes int fallbackDrawableId) {
    TypedValue value = new TypedValue();
    if (context.getTheme().resolveAttribute(attribute, value, true)) {
        return value.resourceId;
    } else {
        return fallbackDrawableId;
    }
}
 
Example 28
Project: https-github.com-hyb1996-NoRootScriptDroid   File: ScriptListWithProgressBarView.java   View source code 4 votes vote down vote up
public ScriptListWithProgressBarView(@NonNull Context context, @Nullable AttributeSet attrs, @AttrRes int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    init();
}
 
Example 29
Project: UsuraKnob   File: SquareFrameLayout.java   View source code 4 votes vote down vote up
public SquareFrameLayout(@NonNull Context context, @Nullable AttributeSet attrs, @AttrRes int defStyleAttr) {
	super(context, attrs, defStyleAttr);
}
 
Example 30
Project: HeadlineNews   File: NewsDetailHeader.java   View source code 4 votes vote down vote up
public NewsDetailHeader(@NonNull Context context, @Nullable AttributeSet attrs, @AttrRes int defStyleAttr) {
    super(context, attrs, defStyleAttr);

    initViews();
}
 
Example 31
Project: AndroidDigIn   File: TouchDelegateViewGroup.java   View source code 4 votes vote down vote up
public TouchDelegateViewGroup(@NonNull Context context, @Nullable AttributeSet attrs, @AttrRes int defStyleAttr) {
    super(context, attrs, defStyleAttr);
}
 
Example 32
Project: CNode-OAuth-Login-Android   File: CNodeOAuthLoginView.java   View source code 4 votes vote down vote up
public CNodeOAuthLoginView(@NonNull Context context, @Nullable AttributeSet attrs, @AttrRes int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    init(context);
}
 
Example 33
Project: elevator-room   File: PersonWidget.java   View source code 4 votes vote down vote up
public PersonWidget(@NonNull Context context, @Nullable AttributeSet attrs, @AttrRes int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    init(context);
}
 
Example 34
Project: Rxjava2.0Demo   File: BallPulseFooter.java   View source code 4 votes vote down vote up
public BallPulseFooter(@NonNull Context context, @Nullable AttributeSet attrs, @AttrRes int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    initView(context, attrs, defStyleAttr);
}
 
Example 35
Project: q-mail   File: AlternateRecipientAdapter.java   View source code 4 votes vote down vote up
private void setCryptoStatusView(RecipientTokenHolder holder, @DrawableRes int cryptoStatusRes,
        @AttrRes int cryptoStatusColorAttr) {
    Resources resources = context.getResources();

    Drawable drawable = resources.getDrawable(cryptoStatusRes);
    // noinspection ConstantConditions, we know the resource exists!
    drawable.mutate();

    int cryptoStatusColor = ThemeUtils.getStyledColor(context, cryptoStatusColorAttr);
    drawable.setColorFilter(cryptoStatusColor, Mode.SRC_ATOP);

    holder.itemCryptoStatusIcon.setImageDrawable(drawable);
    holder.itemCryptoStatus.setVisibility(View.VISIBLE);
}
 
Example 36
Project: CurtainCardView   File: CurtainCardView.java   View source code 4 votes vote down vote up
public CurtainCardView(@NonNull Context context, @Nullable AttributeSet attrs, @AttrRes int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    init(context, attrs);
}
 
Example 37
Project: android-radiobutton-extended   File: CompoundFrameLayout.java   View source code 4 votes vote down vote up
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
public CompoundFrameLayout(@NonNull Context context, @Nullable AttributeSet attrs, @AttrRes int defStyleAttr, @StyleRes int defStyleRes) {
    super(context, attrs, defStyleAttr, defStyleRes);
}
 
Example 38
Project: ui-atoms-android   File: AtomView.java   View source code 4 votes vote down vote up
public AtomView(@NonNull Context context, @Nullable AttributeSet attrs, @AttrRes int defStyleAttr) {
    super(context, attrs, defStyleAttr);
}
 
Example 39
Project: BlackList   File: Utils.java   View source code 4 votes vote down vote up
/**
 * Sets the tint color of the drawable
 **/
public static void setDrawableTint(Context context, Drawable drawable, @AttrRes int colorAttrRes) {
    int colorRes = getResourceId(context, colorAttrRes);
    int color = ContextCompat.getColor(context, colorRes);
    DrawableCompat.setTint(drawable, color);
}
 
Example 40
Project: MusicX-music-player   File: Config.java   View source code 4 votes vote down vote up
@Override
public Config statusBarColorAttr(@AttrRes int colorAttr) {
    return statusBarColor(ATEUtil.resolveColor(mContext, colorAttr));
}