Example usage for android.widget OverScroller getCurrY

List of usage examples for android.widget OverScroller getCurrY

Introduction

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

Prototype

public final int getCurrY() 

Source Link

Document

Returns the current Y offset in the scroll.

Usage

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

@Override
public void run() {
    if (mRecyclerView == null)
        return;//  w ww  .ja va  2  s .  c  o m
    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();
}