Java Code Examples for android.widget.Scroller#getCurrX()
The following examples show how to use
android.widget.Scroller#getCurrX() .
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: VelocityViewPager.java From CoverFlowPager with MIT License | 6 votes |
@Override public void run() { final Scroller scroller = mScroller; boolean animationNotFinished = scroller.computeScrollOffset(); final int x = scroller.getCurrX(); int delta = x - mLastFlingX; trackMotion(delta); if (animationNotFinished) { mLastFlingX = x; post(this); } else { endFling(); } }
Example 2
Source File: Touch.java From PowerFileExplorer with GNU General Public License v3.0 | 4 votes |
public void run() { switch (mTouchMode) { default: return; case TOUCH_MODE_FLING: { // if (mItemCount == 0 || getChildCount() == 0) { // endFling(); // return; // } final Scroller scroller = mScroller; boolean more = scroller.computeScrollOffset(); int x = scroller.getCurrX(); int y = scroller.getCurrY(); // // Pretend that each frame of a fling scroll is a touch scroll // if (delta > 0) { // // List is moving towards the top. Use first view as mMotionPosition // mMotionPosition = mFirstPosition; // final View firstView = getChildAt(0); // mMotionViewOriginalTop = firstView.getTop(); // // // Don't fling more than 1 screen // delta = Math.min(getHeight() - mPaddingBottom - mPaddingTop - 1, delta); // } else { // // List is moving towards the bottom. Use last view as mMotionPosition // int offsetToLast = getChildCount() - 1; // mMotionPosition = mFirstPosition + offsetToLast; // // final View lastView = getChildAt(offsetToLast); // mMotionViewOriginalTop = lastView.getTop(); // // // Don't fling more than 1 screen // delta = Math.max(-(getHeight() - mPaddingBottom - mPaddingTop - 1), delta); // } Layout layout = mWidget.getLayout(); int padding = mWidget.getTotalPaddingTop() + mWidget.getTotalPaddingBottom(); y = Math.min(y, layout.getHeight() - (mWidget.getHeight() - padding)); y = Math.max(y, 0); // final boolean atEnd = trackMotionScroll(delta, delta); Touch.scrollTo( mWidget , layout , x , y ); int delta = mLastFlingY - y; if (more && delta != 0) { mWidget.invalidate(); mLastFlingY = y; mWidget.post(this); } else { endFling(); // if (PROFILE_FLINGING) { // if (mFlingProfilingStarted) { // Debug.stopMethodTracing(); // mFlingProfilingStarted = false; // } // } } break; } } }
Example 3
Source File: EcoGallery.java From samples with Apache License 2.0 | 4 votes |
public void run() { if (mItemCount == 0) { endFling(true); return; } mShouldStopFling = false; final Scroller scroller = mScroller; boolean more = scroller.computeScrollOffset(); final int x = scroller.getCurrX(); // Flip sign to convert finger direction to list items direction // (e.g. finger moving down means list is moving towards the top) int delta = mLastFlingX - x; // Pretend that each frame of a fling scroll is a touch scroll if (delta > 0) { // Moving towards the left. Use first view as mDownTouchPosition mDownTouchPosition = mFirstPosition; // Don't fling more than 1 screen delta = Math.min(getWidth() - getPaddingLeft() - getPaddingRight() - 1, delta); } else { // Moving towards the right. Use last view as mDownTouchPosition int offsetToLast = getChildCount() - 1; mDownTouchPosition = mFirstPosition + offsetToLast; // Don't fling more than 1 screen delta = Math.max(-(getWidth() - getPaddingRight() - getPaddingLeft() - 1), delta); } trackMotionScroll(delta); if (more && !mShouldStopFling) { mLastFlingX = x; post(this); } else { endFling(true); } }
Example 4
Source File: TwoWayAbsListView.java From recent-images with MIT License | 4 votes |
@Override public void run() { if (mTouchMode == TOUCH_MODE_FLING) { if (mItemCount == 0 || getChildCount() == 0) { endFling(); return; } final Scroller scroller = mScroller; boolean more = scroller.computeScrollOffset(); final int x = scroller.getCurrX(); // Flip sign to convert finger direction to list items direction // (e.g. finger moving down means list is moving towards the top) int delta = mLastFlingX - x; // Pretend that each frame of a fling scroll is a touch scroll if (delta > 0) { // List is moving towards the top. Use first view as mMotionPosition mMotionPosition = mFirstPosition; final View firstView = getChildAt(0); mMotionViewOriginalLeft = firstView.getLeft(); // Don't fling more than 1 screen delta = Math.min(getWidth() - getPaddingRight() - getPaddingLeft() - 1, delta); } else { // List is moving towards the bottom. Use last view as mMotionPosition int offsetToLast = getChildCount() - 1; mMotionPosition = mFirstPosition + offsetToLast; final View lastView = getChildAt(offsetToLast); mMotionViewOriginalLeft = lastView.getLeft(); // Don't fling more than 1 screen delta = Math.max(-(getWidth() - getPaddingRight() - getPaddingLeft() - 1), delta); } final boolean atEnd = trackMotionScroll(delta, delta); if (more && !atEnd) { invalidate(); mLastFlingX = x; post(this); } else { endFling(); if (PROFILE_FLINGING && mFlingProfilingStarted) { Debug.stopMethodTracing(); mFlingProfilingStarted = false; } } } else { return; } }
Example 5
Source File: Touch.java From JotaTextEditor with Apache License 2.0 | 4 votes |
public void run() { switch (mTouchMode) { default: return; case TOUCH_MODE_FLING: { // if (mItemCount == 0 || getChildCount() == 0) { // endFling(); // return; // } final Scroller scroller = mScroller; boolean more = scroller.computeScrollOffset(); int x = scroller.getCurrX(); int y = scroller.getCurrY(); // // Pretend that each frame of a fling scroll is a touch scroll // if (delta > 0) { // // List is moving towards the top. Use first view as mMotionPosition // mMotionPosition = mFirstPosition; // final View firstView = getChildAt(0); // mMotionViewOriginalTop = firstView.getTop(); // // // Don't fling more than 1 screen // delta = Math.min(getHeight() - mPaddingBottom - mPaddingTop - 1, delta); // } else { // // List is moving towards the bottom. Use last view as mMotionPosition // int offsetToLast = getChildCount() - 1; // mMotionPosition = mFirstPosition + offsetToLast; // // final View lastView = getChildAt(offsetToLast); // mMotionViewOriginalTop = lastView.getTop(); // // // Don't fling more than 1 screen // delta = Math.max(-(getHeight() - mPaddingBottom - mPaddingTop - 1), delta); // } Layout layout = mWidget.getLayout(); int padding = mWidget.getTotalPaddingTop() + mWidget.getTotalPaddingBottom(); y = Math.min(y, layout.getHeight() - (mWidget.getHeight() - padding)); y = Math.max(y, 0); // final boolean atEnd = trackMotionScroll(delta, delta); Touch.scrollTo( mWidget , layout , x , y ); int delta = mLastFlingY - y; if (more && delta != 0) { mWidget.invalidate(); mLastFlingY = y; mWidget.post(this); } else { endFling(); // if (PROFILE_FLINGING) { // if (mFlingProfilingStarted) { // Debug.stopMethodTracing(); // mFlingProfilingStarted = false; // } // } } break; } } }