Example usage for android.widget OverScroller isFinished

List of usage examples for android.widget OverScroller isFinished

Introduction

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

Prototype

public final boolean isFinished() 

Source Link

Document

Returns whether the scroller has finished scrolling.

Usage

From source file:am.widget.multifunctionalrecyclerview.layoutmanager.PagingOverScroller.java

@Override
public void run() {
    if (mRecyclerView == null)
        return;/* ww  w .j  av  a 2s.c  om*/
    final RecyclerView.LayoutManager layoutManager = mRecyclerView.getLayoutManager();
    if (layoutManager == null) {
        stop();
        return; // no layout, cannot scroll.
    }
    disableRunOnAnimationRequests();
    // keep a local reference so that if it is changed during onAnimation method, it won't
    // cause unexpected behaviors
    final OverScroller scroller = mScroller;

    if (scroller.computeScrollOffset()) {
        final int x = scroller.getCurrX();
        final int y = scroller.getCurrY();
        final int dx = x - mLastFlingX;
        final int dy = y - mLastFlingY;
        mLastFlingX = x;
        mLastFlingY = y;
        if (dx != 0 || dy != 0)
            mRecyclerView.scrollBy(dx, dy);
        if (scroller.isFinished()) {
            if (layoutManager instanceof PagingLayoutManager) {
                ((PagingLayoutManager) layoutManager).onFlingFinish();
            }
        } else {
            postOnAnimation();
        }
    }
    enableRunOnAnimationRequests();
}

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

private void computeScrollX() {
    OverScroller scroller = mFlingScrollerX;
    if (scroller.isFinished()) {
        scroller = mAdjustScrollerX;//from w  w w  .  ja v a 2s.com
        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;//  w w w  . j  a  va 2 s.  c o 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
    }
}