當前位置: 首頁>>代碼示例>>Java>>正文


Java ScrollerCompat.getFinalX方法代碼示例

本文整理匯總了Java中android.support.v4.widget.ScrollerCompat.getFinalX方法的典型用法代碼示例。如果您正苦於以下問題:Java ScrollerCompat.getFinalX方法的具體用法?Java ScrollerCompat.getFinalX怎麽用?Java ScrollerCompat.getFinalX使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.support.v4.widget.ScrollerCompat的用法示例。


在下文中一共展示了ScrollerCompat.getFinalX方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: run

import android.support.v4.widget.ScrollerCompat; //導入方法依賴的package包/類
@Override
public void run() {
    disableRunOnAnimationRequests();
    consumePendingUpdateOperations();
    // keep a local reference so that if it is changed during onAnimation method, it wont cause
    // unexpected behaviors
    final ScrollerCompat scroller = mScroller;
    final SmoothScroller smoothScroller = mLayout.mSmoothScroller;
    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;
        int overscrollX = 0, overscrollY = 0;
        if (mAdapter != null) {
            eatRequestLayout();
            if (dx != 0) {
                final int hresult = mLayout.scrollHorizontallyBy(dx, mRecycler, mState);
                overscrollX = dx - hresult;
            }
            if (dy != 0) {
                final int vresult = mLayout.scrollVerticallyBy(dy, mRecycler, mState);
                overscrollY = dy - vresult;
            }

            if (smoothScroller != null && !smoothScroller.isPendingInitialRun() &&
                    smoothScroller.isRunning()) {
                smoothScroller.onAnimation(dx - overscrollX, dy - overscrollY);
            }
            resumeRequestLayout(false);
        }
        if (!mItemDecorations.isEmpty()) {
            invalidate();
        }

        if (overscrollX != 0 || overscrollY != 0) {
            final int vel = (int) scroller.getCurrVelocity();

            int velX = 0;
            if (overscrollX != x) {
                velX = overscrollX < 0 ? -vel : overscrollX > 0 ? vel : 0;
            }

            int velY = 0;
            if (overscrollY != y) {
                velY = overscrollY < 0 ? -vel : overscrollY > 0 ? vel : 0;
            }

            if (ViewCompat.getOverScrollMode(RecyclerView.this) !=
                    ViewCompat.OVER_SCROLL_NEVER) {
                absorbGlows(velX, velY);
            }
            if ((velX != 0 || overscrollX == x || scroller.getFinalX() == 0) &&
                    (velY != 0 || overscrollY == y || scroller.getFinalY() == 0)) {
                scroller.abortAnimation();
            }
        }

        if (mScrollListener != null && (x != 0 || y != 0)) {
            mScrollListener.onScrolled(dx, dy);
        }

        if (!awakenScrollBars()) {
            invalidate();
        }

        if (scroller.isFinished()) {
            setScrollState(SCROLL_STATE_IDLE);
        } else {
            postOnAnimation();
        }
    }
    // call this after the onAnimation is complete not to have inconsistent callbacks etc.
    if (smoothScroller != null && smoothScroller.isPendingInitialRun()) {
        smoothScroller.onAnimation(0, 0);
    }
    enableRunOnAnimationRequests();
}
 
開發者ID:flzyup,項目名稱:ExRecyclerViewLibrary,代碼行數:81,代碼來源:RecyclerView.java


注:本文中的android.support.v4.widget.ScrollerCompat.getFinalX方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。