FileDocCategorySizeDatePackage
TintDrawableWrapper.javaAPI DocAndroid 5.1 API2388Thu Mar 12 22:22:56 GMT 2015android.support.v7.internal.widget

TintDrawableWrapper

public class TintDrawableWrapper extends DrawableWrapper
A {@link DrawableWrapper} which updates it's color filter using a {@link ColorStateList}.

Fields Summary
private final android.content.res.ColorStateList
mTintStateList
private final PorterDuff.Mode
mTintMode
private int
mCurrentColor
Constructors Summary
public TintDrawableWrapper(android.graphics.drawable.Drawable drawable, android.content.res.ColorStateList tintStateList)

        this(drawable, tintStateList, TintManager.DEFAULT_MODE);
    
public TintDrawableWrapper(android.graphics.drawable.Drawable drawable, android.content.res.ColorStateList tintStateList, PorterDuff.Mode tintMode)

        super(drawable);
        mTintStateList = tintStateList;
        mTintMode = tintMode;
    
Methods Summary
public booleanisStateful()

        return (mTintStateList != null && mTintStateList.isStateful()) || super.isStateful();
    
public booleansetState(int[] stateSet)

        boolean handled = super.setState(stateSet);
        handled = updateTint(stateSet) || handled;
        return handled;
    
private booleanupdateTint(int[] state)

        if (mTintStateList != null) {
            final int color = mTintStateList.getColorForState(state, mCurrentColor);
            if (color != mCurrentColor) {
                if (color != Color.TRANSPARENT) {
                    setColorFilter(color, mTintMode);
                } else {
                    clearColorFilter();
                }
                mCurrentColor = color;
                return true;
            }
        }
        return false;