Search in sources :

Example 1 with RippleView

use of carbon.drawable.ripple.RippleView in project Carbon by ZieIony.

the class Carbon method initRippleDrawable.

public static void initRippleDrawable(RippleView rippleView, TypedArray a, int[] ids) {
    int carbon_rippleColor = ids[0];
    int carbon_rippleStyle = ids[1];
    int carbon_rippleHotspot = ids[2];
    int carbon_rippleRadius = ids[3];
    View view = (View) rippleView;
    if (view.isInEditMode())
        return;
    ColorStateList color = a.getColorStateList(carbon_rippleColor);
    if (color != null) {
        RippleDrawable.Style style = RippleDrawable.Style.values()[a.getInt(carbon_rippleStyle, RippleDrawable.Style.Background.ordinal())];
        boolean useHotspot = a.getBoolean(carbon_rippleHotspot, true);
        int radius = (int) a.getDimension(carbon_rippleRadius, -1);
        rippleView.setRippleDrawable(createRippleDrawable(color, style, view, useHotspot, radius));
    }
}
Also used : ColorStateList(android.content.res.ColorStateList) AnimatedView(carbon.animation.AnimatedView) StateAnimatorView(carbon.widget.StateAnimatorView) StrokeView(carbon.widget.StrokeView) View(android.view.View) InsetView(carbon.widget.InsetView) RippleView(carbon.drawable.ripple.RippleView) TouchMarginView(carbon.widget.TouchMarginView) TintedView(carbon.widget.TintedView) MaxSizeView(carbon.widget.MaxSizeView) ShadowView(carbon.shadow.ShadowView) RippleDrawable(carbon.drawable.ripple.RippleDrawable)

Example 2 with RippleView

use of carbon.drawable.ripple.RippleView in project Carbon by ZieIony.

the class ConstraintLayout method drawChild.

@Override
protected boolean drawChild(@NonNull Canvas canvas, @NonNull View child, long drawingTime) {
    if (child instanceof ShadowView && (Build.VERSION.SDK_INT <= Build.VERSION_CODES.KITKAT_WATCH || ((ShadowView) child).getElevationShadowColor() != null)) {
        ShadowView shadowView = (ShadowView) child;
        shadowView.drawShadow(canvas);
    }
    if (child instanceof RippleView) {
        RippleView rippleView = (RippleView) child;
        RippleDrawable rippleDrawable = rippleView.getRippleDrawable();
        if (rippleDrawable != null && rippleDrawable.getStyle() == RippleDrawable.Style.Borderless) {
            int saveCount = canvas.save(Canvas.MATRIX_SAVE_FLAG);
            canvas.translate(child.getLeft(), child.getTop());
            canvas.concat(MatrixHelper.getMatrix(child));
            rippleDrawable.draw(canvas);
            canvas.restoreToCount(saveCount);
        }
    }
    return super.drawChild(canvas, child, drawingTime);
}
Also used : ShadowView(carbon.shadow.ShadowView) RippleView(carbon.drawable.ripple.RippleView) Paint(android.graphics.Paint) RippleDrawable(carbon.drawable.ripple.RippleDrawable)

Example 3 with RippleView

use of carbon.drawable.ripple.RippleView in project Carbon by ZieIony.

the class FrameLayout method drawChild.

@Override
protected boolean drawChild(@NonNull Canvas canvas, @NonNull View child, long drawingTime) {
    // TODO: why isShown() returns false after being reattached?
    if (child instanceof ShadowView && (Build.VERSION.SDK_INT <= Build.VERSION_CODES.KITKAT_WATCH || ((ShadowView) child).getElevationShadowColor() != null)) {
        ShadowView shadowView = (ShadowView) child;
        shadowView.drawShadow(canvas);
    }
    if (child instanceof RippleView) {
        RippleView rippleView = (RippleView) child;
        RippleDrawable rippleDrawable = rippleView.getRippleDrawable();
        if (rippleDrawable != null && rippleDrawable.getStyle() == RippleDrawable.Style.Borderless) {
            int saveCount = canvas.save(Canvas.MATRIX_SAVE_FLAG);
            canvas.translate(child.getLeft(), child.getTop());
            canvas.concat(MatrixHelper.getMatrix(child));
            rippleDrawable.draw(canvas);
            canvas.restoreToCount(saveCount);
        }
    }
    return super.drawChild(canvas, child, drawingTime);
}
Also used : ShadowView(carbon.shadow.ShadowView) RippleView(carbon.drawable.ripple.RippleView) Paint(android.graphics.Paint) RippleDrawable(carbon.drawable.ripple.RippleDrawable)

Example 4 with RippleView

use of carbon.drawable.ripple.RippleView in project Carbon by ZieIony.

the class RelativeLayout method drawChild.

@Override
protected boolean drawChild(@NonNull Canvas canvas, @NonNull View child, long drawingTime) {
    // TODO: why isShown() returns false after being reattached?
    if (child instanceof ShadowView && (Build.VERSION.SDK_INT <= Build.VERSION_CODES.KITKAT_WATCH || ((ShadowView) child).getElevationShadowColor() != null)) {
        ShadowView shadowView = (ShadowView) child;
        shadowView.drawShadow(canvas);
    }
    if (child instanceof RippleView) {
        RippleView rippleView = (RippleView) child;
        RippleDrawable rippleDrawable = rippleView.getRippleDrawable();
        if (rippleDrawable != null && rippleDrawable.getStyle() == RippleDrawable.Style.Borderless) {
            int saveCount = canvas.save(Canvas.MATRIX_SAVE_FLAG);
            canvas.translate(child.getLeft(), child.getTop());
            canvas.concat(MatrixHelper.getMatrix(child));
            rippleDrawable.draw(canvas);
            canvas.restoreToCount(saveCount);
        }
    }
    return super.drawChild(canvas, child, drawingTime);
}
Also used : ShadowView(carbon.shadow.ShadowView) RippleView(carbon.drawable.ripple.RippleView) Paint(android.graphics.Paint) RippleDrawable(carbon.drawable.ripple.RippleDrawable)

Example 5 with RippleView

use of carbon.drawable.ripple.RippleView in project Carbon by ZieIony.

the class GridLayout method drawChild.

@Override
protected boolean drawChild(@NonNull Canvas canvas, @NonNull View child, long drawingTime) {
    if (child instanceof ShadowView && (Build.VERSION.SDK_INT <= Build.VERSION_CODES.KITKAT_WATCH || ((ShadowView) child).getElevationShadowColor() != null)) {
        ShadowView shadowView = (ShadowView) child;
        shadowView.drawShadow(canvas);
    }
    if (child instanceof RippleView) {
        RippleView rippleView = (RippleView) child;
        RippleDrawable rippleDrawable = rippleView.getRippleDrawable();
        if (rippleDrawable != null && rippleDrawable.getStyle() == RippleDrawable.Style.Borderless) {
            int saveCount = canvas.save(Canvas.MATRIX_SAVE_FLAG);
            canvas.translate(child.getLeft(), child.getTop());
            canvas.concat(MatrixHelper.getMatrix(child));
            rippleDrawable.draw(canvas);
            canvas.restoreToCount(saveCount);
        }
    }
    return super.drawChild(canvas, child, drawingTime);
}
Also used : ShadowView(carbon.shadow.ShadowView) RippleView(carbon.drawable.ripple.RippleView) Paint(android.graphics.Paint) RippleDrawable(carbon.drawable.ripple.RippleDrawable)

Aggregations

RippleDrawable (carbon.drawable.ripple.RippleDrawable)14 RippleView (carbon.drawable.ripple.RippleView)14 ShadowView (carbon.shadow.ShadowView)14 Paint (android.graphics.Paint)13 ColorStateList (android.content.res.ColorStateList)1 View (android.view.View)1 AnimatedView (carbon.animation.AnimatedView)1 InsetView (carbon.widget.InsetView)1 MaxSizeView (carbon.widget.MaxSizeView)1 StateAnimatorView (carbon.widget.StateAnimatorView)1 StrokeView (carbon.widget.StrokeView)1 TintedView (carbon.widget.TintedView)1 TouchMarginView (carbon.widget.TouchMarginView)1