Example usage for android.widget EdgeEffect draw

List of usage examples for android.widget EdgeEffect draw

Introduction

In this page you can find the example usage for android.widget EdgeEffect draw.

Prototype

public boolean draw(Canvas canvas) 

Source Link

Document

Draw into the provided canvas.

Usage

From source file:com.bitflake.counter.HorizontalPicker.java

private void drawEdgeEffect(Canvas canvas, EdgeEffect edgeEffect, int degrees) {

    if (canvas == null || edgeEffect == null || (degrees != 90 && degrees != 270)) {
        return;//from  ww  w  .ja  v a  2 s  .  com
    }

    if (!edgeEffect.isFinished()) {
        final int restoreCount = canvas.getSaveCount();
        final int width = getWidth();
        final int height = getHeight();

        canvas.rotate(degrees);

        if (degrees == 270) {
            canvas.translate(-height, Math.max(0, getScrollX()));
        } else { // 90
            canvas.translate(0, -(Math.max(getScrollRange(), getScaleX()) + width));
        }

        edgeEffect.setSize(height, width);
        if (edgeEffect.draw(canvas)) {
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
                postInvalidateOnAnimation();
            } else {
                postInvalidate();
            }
        }

        canvas.restoreToCount(restoreCount);
    }

}