Example usage for android.widget EdgeEffect setSize

List of usage examples for android.widget EdgeEffect setSize

Introduction

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

Prototype

public void setSize(int width, int height) 

Source Link

Document

Set the size of this edge effect in pixels.

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;/* w w w  .  j a v a2 s  .  c  o  m*/
    }

    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);
    }

}