当前位置: 首页>>代码示例>>Java>>正文


Java ScrollerCompat.getFinalY方法代码示例

本文整理汇总了Java中android.support.v4.widget.ScrollerCompat.getFinalY方法的典型用法代码示例。如果您正苦于以下问题:Java ScrollerCompat.getFinalY方法的具体用法?Java ScrollerCompat.getFinalY怎么用?Java ScrollerCompat.getFinalY使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.support.v4.widget.ScrollerCompat的用法示例。


在下文中一共展示了ScrollerCompat.getFinalY方法的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.getFinalY方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。