Search in sources :

Example 1 with DefaultPrimaryColorStateList

use of carbon.drawable.DefaultPrimaryColorStateList in project Carbon by ZieIony.

the class Button method initButton.

private void initButton(AttributeSet attrs, int defStyleAttr) {
    TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.Button, defStyleAttr, R.style.carbon_Button);
    int ap = a.getResourceId(R.styleable.Button_android_textAppearance, -1);
    if (ap != -1)
        setTextAppearanceInternal(ap);
    for (int i = 0; i < a.getIndexCount(); i++) {
        int attr = a.getIndex(i);
        if (attr == R.styleable.Button_carbon_textAllCaps) {
            setAllCaps(a.getBoolean(R.styleable.Button_carbon_textAllCaps, true));
        } else if (!isInEditMode() && attr == R.styleable.Button_carbon_fontPath) {
            String path = a.getString(attr);
            Typeface typeface = TypefaceUtils.getTypeface(getContext(), path);
            setTypeface(typeface);
        } else if (attr == R.styleable.Button_carbon_fontFamily) {
            int textStyle = a.getInt(R.styleable.Button_android_textStyle, 0);
            Typeface typeface = TypefaceUtils.getTypeface(getContext(), a.getString(attr), textStyle);
            setTypeface(typeface);
        }
    }
    TypedValue bg = new TypedValue();
    a.getValue(R.styleable.Button_android_background, bg);
    if (bg.type >= TypedValue.TYPE_FIRST_COLOR_INT && bg.type <= TypedValue.TYPE_LAST_COLOR_INT && bg.data == 0)
        setBackgroundDrawable(new ColorStateListDrawable(AnimatedColorStateList.fromList(new DefaultPrimaryColorStateList(getContext()), animation -> postInvalidate())));
    Carbon.initRippleDrawable(this, a, rippleIds);
    Carbon.initElevation(this, a, elevationIds);
    Carbon.initTint(this, a, tintIds);
    Carbon.initAnimations(this, a, animationIds);
    Carbon.initTouchMargin(this, a, touchMarginIds);
    Carbon.initHtmlText(this, a, R.styleable.Button_carbon_htmlText);
    Carbon.initStroke(this, a, strokeIds);
    setCornerRadius(a.getDimension(R.styleable.Button_carbon_cornerRadius, 0));
    a.recycle();
}
Also used : Typeface(android.graphics.Typeface) Context(android.content.Context) Path(android.graphics.Path) Rect(android.graphics.Rect) NEEDS_PROXY(com.nineoldandroids.view.animation.AnimatorProxy.NEEDS_PROXY) ShadowShape(carbon.shadow.ShadowShape) AnimatorProxy.wrap(com.nineoldandroids.view.animation.AnimatorProxy.wrap) AnimatorListenerAdapter(com.nineoldandroids.animation.AnimatorListenerAdapter) AnimatedView(carbon.animation.AnimatedView) ViewOutlineProvider(android.view.ViewOutlineProvider) NonNull(android.support.annotation.NonNull) Drawable(android.graphics.drawable.Drawable) TypedArray(android.content.res.TypedArray) ColorStateList(android.content.res.ColorStateList) MatrixHelper(carbon.internal.MatrixHelper) AttributeSet(android.util.AttributeSet) MotionEvent(android.view.MotionEvent) ShadowGenerator(carbon.shadow.ShadowGenerator) View(android.view.View) RippleDrawable(carbon.drawable.ripple.RippleDrawable) Canvas(android.graphics.Canvas) ViewCompat(android.support.v4.view.ViewCompat) Animation(android.view.animation.Animation) Matrix(android.graphics.Matrix) Build(android.os.Build) TargetApi(android.annotation.TargetApi) DefaultPrimaryColorStateList(carbon.drawable.DefaultPrimaryColorStateList) RectF(android.graphics.RectF) ValueAnimator(com.nineoldandroids.animation.ValueAnimator) R(carbon.R) RippleView(carbon.drawable.ripple.RippleView) TypefaceUtils(carbon.internal.TypefaceUtils) Animator(com.nineoldandroids.animation.Animator) StateAnimator(carbon.animation.StateAnimator) ColorStateListDrawable(carbon.drawable.ColorStateListDrawable) PorterDuff(android.graphics.PorterDuff) Shadow(carbon.shadow.Shadow) Carbon(carbon.Carbon) TypedValue(android.util.TypedValue) AllCapsTransformationMethod(carbon.internal.AllCapsTransformationMethod) PorterDuffColorFilter(android.graphics.PorterDuffColorFilter) Transformation(android.view.animation.Transformation) Paint(android.graphics.Paint) AnimatedColorStateList(carbon.animation.AnimatedColorStateList) ShadowView(carbon.shadow.ShadowView) AnimUtils(carbon.animation.AnimUtils) Typeface(android.graphics.Typeface) DefaultPrimaryColorStateList(carbon.drawable.DefaultPrimaryColorStateList) TypedArray(android.content.res.TypedArray) ColorStateListDrawable(carbon.drawable.ColorStateListDrawable) Paint(android.graphics.Paint) TypedValue(android.util.TypedValue)

Aggregations

TargetApi (android.annotation.TargetApi)1 Context (android.content.Context)1 ColorStateList (android.content.res.ColorStateList)1 TypedArray (android.content.res.TypedArray)1 Canvas (android.graphics.Canvas)1 Matrix (android.graphics.Matrix)1 Paint (android.graphics.Paint)1 Path (android.graphics.Path)1 PorterDuff (android.graphics.PorterDuff)1 PorterDuffColorFilter (android.graphics.PorterDuffColorFilter)1 Rect (android.graphics.Rect)1 RectF (android.graphics.RectF)1 Typeface (android.graphics.Typeface)1 Drawable (android.graphics.drawable.Drawable)1 Build (android.os.Build)1 NonNull (android.support.annotation.NonNull)1 ViewCompat (android.support.v4.view.ViewCompat)1 AttributeSet (android.util.AttributeSet)1 TypedValue (android.util.TypedValue)1 MotionEvent (android.view.MotionEvent)1