Example usage for android.widget OverScroller getStartX

List of usage examples for android.widget OverScroller getStartX

Introduction

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

Prototype

public final int getStartX() 

Source Link

Document

Returns the start X offset in the scroll.

Usage

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

private void computeScrollX() {
    OverScroller scroller = mFlingScrollerX;
    if (scroller.isFinished()) {
        scroller = mAdjustScrollerX;/*  w  w w  . j  av a  2s .co m*/
        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;//ww  w .java 2  s  . co m
        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
    }
}