Search in sources :

Example 1 with AnimatedColorStateList

use of carbon.animation.AnimatedColorStateList in project Carbon by ZieIony.

the class CheckableDrawable method onStateChange.

@Override
protected boolean onStateChange(int[] states) {
    boolean changed = false;
    if (states != null) {
        boolean newChecked = false;
        boolean newIndeterminate = false;
        boolean newEnabled = false;
        for (int state : states) {
            if (state == android.R.attr.state_checked)
                newChecked = true;
            if (state == R.attr.carbon_state_indeterminate)
                newIndeterminate = true;
            if (state == android.R.attr.state_enabled)
                newEnabled = true;
        }
        CheckedState newCheckedState = newIndeterminate ? CheckedState.INDETERMINATE : newChecked ? CheckedState.CHECKED : CheckedState.UNCHECKED;
        if (checkedState != newCheckedState) {
            setChecked(newCheckedState);
            changed = true;
        }
        if (enabled != newEnabled) {
            setEnabled(newEnabled);
            changed = true;
        }
    }
    boolean result = super.onStateChange(states);
    if (changed && tint != null && tint instanceof AnimatedColorStateList)
        ((AnimatedColorStateList) tint).setState(states);
    return result && changed;
}
Also used : Paint(android.graphics.Paint) AnimatedColorStateList(carbon.animation.AnimatedColorStateList)

Example 2 with AnimatedColorStateList

use of carbon.animation.AnimatedColorStateList in project Carbon by ZieIony.

the class Button method drawableStateChanged.

@Override
protected void drawableStateChanged() {
    super.drawableStateChanged();
    if (rippleDrawable != null && rippleDrawable.getStyle() != RippleDrawable.Style.Background)
        rippleDrawable.setState(getDrawableState());
    if (stateAnimator != null)
        stateAnimator.setState(getDrawableState());
    ColorStateList textColors = getTextColors();
    if (textColors instanceof AnimatedColorStateList)
        ((AnimatedColorStateList) textColors).setState(getDrawableState());
    if (tint != null && tint instanceof AnimatedColorStateList)
        ((AnimatedColorStateList) tint).setState(getDrawableState());
    if (backgroundTint != null && backgroundTint instanceof AnimatedColorStateList)
        ((AnimatedColorStateList) backgroundTint).setState(getDrawableState());
    if (shadow != null && shadowColor != null)
        shadowColorFilter = new PorterDuffColorFilter(shadowColor.getColorForState(getDrawableState(), shadowColor.getDefaultColor()), PorterDuff.Mode.MULTIPLY);
}
Also used : ColorStateList(android.content.res.ColorStateList) DefaultPrimaryColorStateList(carbon.drawable.DefaultPrimaryColorStateList) AnimatedColorStateList(carbon.animation.AnimatedColorStateList) PorterDuffColorFilter(android.graphics.PorterDuffColorFilter) AnimatedColorStateList(carbon.animation.AnimatedColorStateList)

Example 3 with AnimatedColorStateList

use of carbon.animation.AnimatedColorStateList in project Carbon by ZieIony.

the class EditText method drawableStateChanged.

@Override
protected void drawableStateChanged() {
    super.drawableStateChanged();
    if (rippleDrawable != null && rippleDrawable.getStyle() != RippleDrawable.Style.Background)
        rippleDrawable.setState(getDrawableState());
    if (stateAnimator != null)
        stateAnimator.setState(getDrawableState());
    ColorStateList textColors = getTextColors();
    if (textColors instanceof AnimatedColorStateList)
        ((AnimatedColorStateList) textColors).setState(getDrawableState());
    if (tint != null && tint instanceof AnimatedColorStateList)
        ((AnimatedColorStateList) tint).setState(getDrawableState());
    if (backgroundTint != null && backgroundTint instanceof AnimatedColorStateList)
        ((AnimatedColorStateList) backgroundTint).setState(getDrawableState());
}
Also used : ColorStateList(android.content.res.ColorStateList) DefaultNormalColorStateList(carbon.drawable.DefaultNormalColorStateList) DefaultColorStateList(carbon.drawable.DefaultColorStateList) AnimatedColorStateList(carbon.animation.AnimatedColorStateList) AnimatedColorStateList(carbon.animation.AnimatedColorStateList)

Example 4 with AnimatedColorStateList

use of carbon.animation.AnimatedColorStateList in project Carbon by ZieIony.

the class TextView method drawableStateChanged.

@Override
protected void drawableStateChanged() {
    super.drawableStateChanged();
    if (rippleDrawable != null && rippleDrawable.getStyle() != RippleDrawable.Style.Background)
        rippleDrawable.setState(getDrawableState());
    if (stateAnimator != null)
        stateAnimator.setState(getDrawableState());
    ColorStateList textColors = getTextColors();
    if (textColors instanceof AnimatedColorStateList)
        ((AnimatedColorStateList) textColors).setState(getDrawableState());
    if (tint != null && tint instanceof AnimatedColorStateList)
        ((AnimatedColorStateList) tint).setState(getDrawableState());
    if (backgroundTint != null && backgroundTint instanceof AnimatedColorStateList)
        ((AnimatedColorStateList) backgroundTint).setState(getDrawableState());
}
Also used : ColorStateList(android.content.res.ColorStateList) DefaultColorStateList(carbon.drawable.DefaultColorStateList) AnimatedColorStateList(carbon.animation.AnimatedColorStateList) AnimatedColorStateList(carbon.animation.AnimatedColorStateList)

Aggregations

AnimatedColorStateList (carbon.animation.AnimatedColorStateList)4 ColorStateList (android.content.res.ColorStateList)3 DefaultColorStateList (carbon.drawable.DefaultColorStateList)2 Paint (android.graphics.Paint)1 PorterDuffColorFilter (android.graphics.PorterDuffColorFilter)1 DefaultNormalColorStateList (carbon.drawable.DefaultNormalColorStateList)1 DefaultPrimaryColorStateList (carbon.drawable.DefaultPrimaryColorStateList)1