List of usage examples for android.widget OverScroller computeScrollOffset
public boolean computeScrollOffset()
From source file:am.widget.multifunctionalrecyclerview.layoutmanager.PagingOverScroller.java
@Override public void run() { if (mRecyclerView == null) return;/*from w ww. jav a 2 s. co 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(); }
From source file:com.lab47billion.appchooser.HorizontalPicker.java
private void computeScrollX() { OverScroller scroller = mFlingScrollerX; if (scroller.isFinished()) { scroller = mAdjustScrollerX;/* w w w. j a va2s. co m*/ 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;// ww w.ja 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 } }