Example usage for android.support.v4.graphics.drawable DrawableCompat setTintList

List of usage examples for android.support.v4.graphics.drawable DrawableCompat setTintList

Introduction

In this page you can find the example usage for android.support.v4.graphics.drawable DrawableCompat setTintList.

Prototype

public static void setTintList(Drawable drawable, ColorStateList colorStateList) 

Source Link

Usage

From source file:com.bryan.lib.util.TintDrawable.java

public static Drawable tintDrawableList(Drawable drawable, ColorStateList colors) {
    final Drawable wrappedDrawable = DrawableCompat.wrap(drawable);
    DrawableCompat.setTintList(wrappedDrawable, colors);
    return wrappedDrawable;
}

From source file:org.mozilla.gecko.util.DrawableUtil.java

public static Drawable tintDrawableWithStateList(@NonNull final Drawable drawable,
        @NonNull final ColorStateList colorList) {
    final Drawable wrappedDrawable = DrawableCompat.wrap(drawable.mutate());
    DrawableCompat.setTintList(wrappedDrawable, colorList);
    return wrappedDrawable;
}

From source file:com.vinidsl.googleioextended.helper.TintHelper.java

public static Drawable tint(Drawable drawable, ColorStateList stateList) {
    drawable = DrawableCompat.wrap(drawable);
    DrawableCompat.setTintList(drawable, stateList);
    DrawableCompat.setTintMode(drawable, PorterDuff.Mode.SRC_IN);
    return drawable;
}

From source file:com.bobomee.android.common.util.EditUtil.java

private static Drawable tintDrawable(Drawable drawable, ColorStateList colors) {
    final Drawable wrappedDrawable = DrawableCompat.wrap(drawable);
    DrawableCompat.setTintList(wrappedDrawable, colors);
    return wrappedDrawable;
}

From source file:me.henrytao.mdcore.core.MdCompat.java

public static Drawable createDrawableTint(Drawable drawable, int[] drawableState, ColorStateList tintList,
        PorterDuff.Mode tintMode) {/*  ww  w  .  jav a2 s.  c  om*/
    if (drawable != null && (tintList != null || tintMode != null)) {
        drawable = DrawableCompat.wrap(drawable).mutate();
        if (tintList != null) {
            DrawableCompat.setTintList(drawable, tintList);
        }
        if (tintMode != null) {
            DrawableCompat.setTintMode(drawable, tintMode);
        }
        if (drawable.isStateful() && drawableState != null) {
            drawable.setState(drawableState);
        }
    }
    return drawable;
}

From source file:com.doctoror.fuckoffmusicplayer.presentation.util.DrawableUtils.java

@Nullable
public static Drawable getTintedDrawable(@Nullable Drawable drawable, @Nullable final ColorStateList tint) {
    if (drawable != null) {
        drawable = DrawableCompat.wrap(drawable);
        DrawableCompat.setTintList(drawable, tint);
    }/*from  w  w w  .ja  v a  2 s .co  m*/
    return drawable;
}

From source file:de.vanita5.twittnuker.view.themed.ThemedSwitch.java

@Override
public void setThemeTintColor(ColorStateList color) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        DrawableCompat.setTintList(getThumbDrawable(), color);
        DrawableCompat.setTintList(getTrackDrawable(), color);
    }//from   www  .j  a va2  s .  c o m
}

From source file:org.getlantern.firetweet.view.themed.ThemedSwitch.java

@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
private void setDrawableTint(ColorStateList color) {
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN)
        return;/*  w  w w.  j av a2 s .c om*/
    DrawableCompat.setTintList(getThumbDrawable(), color);
    DrawableCompat.setTintList(getTrackDrawable(), color);
}

From source file:org.telegram.ui.Cells.DrawerActionCell.java

public void setTextAndIcon(String text, int resId) {
    try {//from   w  ww  .j a va2 s.  c  o  m
        textView.setText(text);
        Drawable dr = getContext().getDrawable(resId);
        if (dr != null) {
            DrawableCompat.setTintList(dr, ColorStateList.valueOf(
                    ContextCompat.getColor(getContext(), R.color.secondary_text)) /*textView.getTextColors()*/);
            textView.setCompoundDrawablesWithIntrinsicBounds(dr, null, null, null);
        }
    } catch (Throwable e) {
        FileLog.e("tmessages", e);
    }
}

From source file:android.support.design.widget.FloatingActionButtonLollipop.java

@Override
void setBackgroundDrawable(ColorStateList backgroundTint, PorterDuff.Mode backgroundTintMode, int rippleColor,
        int borderWidth) {
    // Now we need to tint the shape background with the tint
    mShapeDrawable = DrawableCompat.wrap(createShapeDrawable());
    DrawableCompat.setTintList(mShapeDrawable, backgroundTint);
    if (backgroundTintMode != null) {
        DrawableCompat.setTintMode(mShapeDrawable, backgroundTintMode);
    }/*www.  ja  va2s. c  om*/

    final Drawable rippleContent;
    if (borderWidth > 0) {
        mBorderDrawable = createBorderDrawable(borderWidth, backgroundTint);
        rippleContent = new LayerDrawable(new Drawable[] { mBorderDrawable, mShapeDrawable });
    } else {
        mBorderDrawable = null;
        rippleContent = mShapeDrawable;
    }

    mRippleDrawable = new RippleDrawable(ColorStateList.valueOf(rippleColor), rippleContent, null);

    mContentBackground = mRippleDrawable;

    mShadowViewDelegate.setBackgroundDrawable(mRippleDrawable);
}