Java Code Examples for android.widget.Scroller#getFinalY()
The following examples show how to use
android.widget.Scroller#getFinalY() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NumberPicker.java From iGap-Android with GNU Affero General Public License v3.0 | 6 votes |
private boolean moveToFinalScrollerPosition(Scroller scroller) { scroller.forceFinished(true); 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; }
Example 2
Source File: NumberPicker.java From DateTimePicker with Apache License 2.0 | 6 votes |
/** * Move to the final position of a scroller. Ensures to force finish the scroller * and if it is not at its final position a scroll of the selector wheel is * performed to fast forward to the final position. * * @param scroller The scroller to whose final position to get. * @return True of the a move was performed, i.e. the scroller was not in final position. */ private boolean moveToFinalScrollerPosition(Scroller scroller) { scroller.forceFinished(true); 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; }
Example 3
Source File: GravitySnapHelper.java From GravitySnapHelper with Apache License 2.0 | 6 votes |
@Override @NonNull public int[] calculateScrollDistance(int velocityX, int velocityY) { if (recyclerView == null || (verticalHelper == null && horizontalHelper == null) || (maxFlingDistance == FLING_DISTANCE_DISABLE && maxFlingSizeFraction == FLING_SIZE_FRACTION_DISABLE)) { return super.calculateScrollDistance(velocityX, velocityY); } final int[] out = new int[2]; Scroller scroller = new Scroller(recyclerView.getContext(), new DecelerateInterpolator()); int maxDistance = getFlingDistance(); scroller.fling(0, 0, velocityX, velocityY, -maxDistance, maxDistance, -maxDistance, maxDistance); out[0] = scroller.getFinalX(); out[1] = scroller.getFinalY(); return out; }
Example 4
Source File: NumberPicker.java From ticdesign with Apache License 2.0 | 6 votes |
/** * Move to the final position of a scroller. Ensures to force finish the scroller * and if it is not at its final position a scroll of the selector wheel is * performed to fast forward to the final position. * * @param scroller The scroller to whose final position to get. * @return True of the a move was performed, i.e. the scroller was not in final position. */ private boolean moveToFinalScrollerPosition(Scroller scroller) { scroller.forceFinished(true); 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; amountToScroll %= mSelectorElementHeight; scrollBy(0, amountToScroll); return true; } return false; }
Example 5
Source File: NumberPicker.java From NewXmPluginSDK with Apache License 2.0 | 6 votes |
/** * Move to the final position of a scroller. Ensures to force finish the scroller * and if it is not at its final position a scroll of the selector wheel is * performed to fast forward to the final position. * * @param scroller The scroller to whose final position to get. * @return True of the a move was performed, i.e. the scroller was not in final position. */ private boolean moveToFinalScrollerPosition(Scroller scroller) { scroller.forceFinished(true); 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; }
Example 6
Source File: GravitySnapHelper.java From SuntimesWidget with GNU General Public License v3.0 | 6 votes |
@Override @NonNull public int[] calculateScrollDistance(int velocityX, int velocityY) { if (recyclerView == null || (verticalHelper == null && horizontalHelper == null) || (maxFlingDistance == FLING_DISTANCE_DISABLE && maxFlingSizeFraction == FLING_SIZE_FRACTION_DISABLE)) { return super.calculateScrollDistance(velocityX, velocityY); } final int[] out = new int[2]; Scroller scroller = new Scroller(recyclerView.getContext(), new DecelerateInterpolator()); int maxDistance = getFlingDistance(); scroller.fling(0, 0, velocityX, velocityY, -maxDistance, maxDistance, -maxDistance, maxDistance); out[0] = scroller.getFinalX(); out[1] = scroller.getFinalY(); return out; }