Example usage for android.widget Scroller getCurrY

List of usage examples for android.widget Scroller getCurrY

Introduction

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

Prototype

public final int getCurrY() 

Source Link

Document

Returns the current Y offset in the scroll.

Usage

From source file:org.telegram.ui.Components.NumberPicker.java

private boolean moveToFinalScrollerPosition(Scroller scroller) {
    scroller.forceFinished(true);/* w  w  w.  java 2s  . c  o  m*/
    int amountToScroll = scroller.getFinalY() - scroller.getCurrY();
    int futureScrollOffset = (mCurrentScrollOffset + amountToScroll) % mSelectorElementHeight;
    int overshootAdjustment = mInitialScrollOffset - futureScrollOffset;
    if (overshootAdjustment != 0) {
        if (Math.abs(overshootAdjustment) > mSelectorElementHeight / 2) {
            if (overshootAdjustment > 0) {
                overshootAdjustment -= mSelectorElementHeight;
            } else {
                overshootAdjustment += mSelectorElementHeight;
            }
        }
        amountToScroll += overshootAdjustment;
        scrollBy(0, amountToScroll);
        return true;
    }
    return false;
}

From source file:org.telegram.ui.Components.NumberPicker.java

@Override
public void computeScroll() {
    Scroller scroller = mFlingScroller;
    if (scroller.isFinished()) {
        scroller = mAdjustScroller;// www  .j  av a2  s.  c  o m
        if (scroller.isFinished()) {
            return;
        }
    }
    scroller.computeScrollOffset();
    int currentScrollerY = scroller.getCurrY();
    if (mPreviousScrollerY == 0) {
        mPreviousScrollerY = scroller.getStartY();
    }
    scrollBy(0, currentScrollerY - mPreviousScrollerY);
    mPreviousScrollerY = currentScrollerY;
    if (scroller.isFinished()) {
        onScrollerFinished(scroller);
    } else {
        invalidate();
    }
}