Search in sources :

Example 16 with RippleDrawable

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

the class AppBarLayout 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 17 with RippleDrawable

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

the class Carbon method createRippleDrawable.

public static RippleDrawable createRippleDrawable(ColorStateList color, RippleDrawable.Style style, View view, boolean useHotspot, int radius) {
    RippleDrawable rippleDrawable;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        rippleDrawable = new RippleDrawableMarshmallow(color, style == RippleDrawable.Style.Background ? view.getBackground() : null, style);
    } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        rippleDrawable = new RippleDrawableLollipop(color, style == RippleDrawable.Style.Background ? view.getBackground() : null, style);
    } else {
        rippleDrawable = new RippleDrawableFroyo(color, style == RippleDrawable.Style.Background ? view.getBackground() : null, style);
    }
    rippleDrawable.setCallback(view);
    rippleDrawable.setHotspotEnabled(useHotspot);
    rippleDrawable.setRadius(radius);
    return rippleDrawable;
}
Also used : RippleDrawableFroyo(carbon.drawable.ripple.RippleDrawableFroyo) RippleDrawableMarshmallow(carbon.drawable.ripple.RippleDrawableMarshmallow) RippleDrawableLollipop(carbon.drawable.ripple.RippleDrawableLollipop) RippleDrawable(carbon.drawable.ripple.RippleDrawable)

Example 18 with RippleDrawable

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

the class Carbon method createRippleDrawable.

public static RippleDrawable createRippleDrawable(ColorStateList color, RippleDrawable.Style style, View view, Drawable background, boolean useHotspot, int radius) {
    RippleDrawable rippleDrawable;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        rippleDrawable = new RippleDrawableMarshmallow(color, background, style);
    } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        rippleDrawable = new RippleDrawableLollipop(color, background, style);
    } else {
        rippleDrawable = new RippleDrawableFroyo(color, background, style);
    }
    rippleDrawable.setCallback(view);
    rippleDrawable.setHotspotEnabled(useHotspot);
    rippleDrawable.setRadius(radius);
    return rippleDrawable;
}
Also used : RippleDrawableFroyo(carbon.drawable.ripple.RippleDrawableFroyo) RippleDrawableMarshmallow(carbon.drawable.ripple.RippleDrawableMarshmallow) RippleDrawableLollipop(carbon.drawable.ripple.RippleDrawableLollipop) RippleDrawable(carbon.drawable.ripple.RippleDrawable)

Example 19 with RippleDrawable

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

the class RecyclerView method drawChild.

@Override
public 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 20 with RippleDrawable

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

the class LinearLayout 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)

Aggregations

RippleDrawable (carbon.drawable.ripple.RippleDrawable)20 Paint (android.graphics.Paint)15 RippleView (carbon.drawable.ripple.RippleView)14 ShadowView (carbon.shadow.ShadowView)13 Drawable (android.graphics.drawable.Drawable)5 CheckableDrawable (carbon.drawable.CheckableDrawable)3 PorterDuffColorFilter (android.graphics.PorterDuffColorFilter)2 RippleDrawableFroyo (carbon.drawable.ripple.RippleDrawableFroyo)2 RippleDrawableLollipop (carbon.drawable.ripple.RippleDrawableLollipop)2 RippleDrawableMarshmallow (carbon.drawable.ripple.RippleDrawableMarshmallow)2 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 PorterDuff (android.graphics.PorterDuff)1 Rect (android.graphics.Rect)1 Build (android.os.Build)1 NonNull (android.support.annotation.NonNull)1 ViewCompat (android.support.v4.view.ViewCompat)1