Example usage for android.widget Scroller getFinalY

List of usage examples for android.widget Scroller getFinalY

Introduction

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

Prototype

public final int getFinalY() 

Source Link

Document

Returns where the scroll will end.

Usage

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

private boolean moveToFinalScrollerPosition(Scroller scroller) {
    scroller.forceFinished(true);//from  w ww .ja va  2  s .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;
}