Example usage for android.widget OverScroller getCurrVelocity

List of usage examples for android.widget OverScroller getCurrVelocity

Introduction

In this page you can find the example usage for android.widget OverScroller getCurrVelocity.

Prototype

public float getCurrVelocity() 

Source Link

Document

Returns the absolute value of the current velocity.

Usage

From source file:com.lab47billion.appchooser.HorizontalPicker.java

private void computeScrollX() {
    OverScroller scroller = mFlingScrollerX;
    if (scroller.isFinished()) {
        scroller = mAdjustScrollerX;//from  w  ww .  j  a va 2 s .  c om
        if (scroller.isFinished()) {
            return;
        }
    }

    if (scroller.computeScrollOffset()) {

        int currentScrollerX = scroller.getCurrX();
        if (mPreviousScrollerX == Integer.MIN_VALUE) {
            mPreviousScrollerX = scroller.getStartX();
        }

        int range = getScrollRange();
        if (mPreviousScrollerX >= 0 && currentScrollerX < 0) {
            mLeftEdgeEffect.onAbsorb((int) scroller.getCurrVelocity());
        } else if (mPreviousScrollerX <= range && currentScrollerX > range) {
            mRightEdgeEffect.onAbsorb((int) scroller.getCurrVelocity());
        }

        overScrollBy(currentScrollerX - mPreviousScrollerX, 0, mPreviousScrollerX, getScrollY(),
                getScrollRange(), 0, mOverscrollDistance, 0, false);
        mPreviousScrollerX = currentScrollerX;

        if (scroller.isFinished()) {
            onScrollerFinishedX(scroller);
        }

        postInvalidate();
        //            postInvalidateOnAnimation(); // TODO
    }
}

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

private void computeScrollX() {
    OverScroller scroller = flingScrollerX;
    if (scroller.isFinished()) {
        scroller = adjustScrollerX;//from ww w .j  a v a 2 s .  c om
        if (scroller.isFinished()) {
            return;
        }
    }

    if (scroller.computeScrollOffset()) {

        int currentScrollerX = scroller.getCurrX();
        if (previousScrollerX == Integer.MIN_VALUE) {
            previousScrollerX = scroller.getStartX();
        }

        int range = getScrollRange();
        if (previousScrollerX >= 0 && currentScrollerX < 0) {
            leftEdgeEffect.onAbsorb((int) scroller.getCurrVelocity());
        } else if (previousScrollerX <= range && currentScrollerX > range) {
            rightEdgeEffect.onAbsorb((int) scroller.getCurrVelocity());
        }

        overScrollBy(currentScrollerX - previousScrollerX, 0, previousScrollerX, getScrollY(), getScrollRange(),
                0, overscrollDistance, 0, false);
        previousScrollerX = currentScrollerX;

        if (scroller.isFinished()) {
            onScrollerFinishedX(scroller);
        }

        postInvalidate();
        //            postInvalidateOnAnimation(); // TODO
    }
}