Example usage for android.widget EdgeEffect onAbsorb

List of usage examples for android.widget EdgeEffect onAbsorb

Introduction

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

Prototype

public void onAbsorb(int velocity) 

Source Link

Document

Call when the effect absorbs an impact at the given velocity.

Usage

From source file:net.simonvt.staggeredgridview.StaggeredGridView.java

@Override
public void computeScroll() {
    if (scroller.computeScrollOffset()) {
        final int y = scroller.getCurrY();
        final int dy = (int) (y - lastTouchY);
        lastTouchY = y;//from  w w  w .j a  v  a 2 s.c  o  m
        final boolean stopped = !trackMotionScroll(dy, false);

        if (!stopped && !scroller.isFinished()) {
            postInvalidateOnAnimation();
        } else {
            if (stopped) {
                final int overScrollMode = getOverScrollMode();
                if (overScrollMode != OVER_SCROLL_NEVER) {
                    final EdgeEffect edge;
                    if (dy > 0) {
                        edge = topEdge;
                    } else {
                        edge = bottomEdge;
                    }
                    edge.onAbsorb(Math.abs((int) scroller.getCurrVelocity()));
                    postInvalidateOnAnimation();
                }
                scroller.abortAnimation();
            }
            touchMode = TOUCH_MODE_IDLE;
        }
    }
}