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


Java Scroller.getCurrY方法代码示例

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


在下文中一共展示了Scroller.getCurrY方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: run

import android.widget.Scroller; //导入方法依赖的package包/类
@Override
public void run() {

    final Scroller scroller = mScroller;
    boolean animationNotFinished = scroller.computeScrollOffset();
    final int y = scroller.getCurrY();
    int delta = y - mLastFlingY;

    trackMotion(delta);

    if (animationNotFinished) {
        mLastFlingY = y;
        post(this);
    } else {
        endFling();
    }

}
 
开发者ID:sinhaDroid,项目名称:BlogBookApp,代码行数:19,代码来源:VelocityViewPager.java

示例2: moveToFinalScrollerPosition

import android.widget.Scroller; //导入方法依赖的package包/类
/**
 * 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;
}
 
开发者ID:Gericop,项目名称:DateTimePicker,代码行数:28,代码来源:NumberPicker.java

示例3: computeScroll

import android.widget.Scroller; //导入方法依赖的package包/类
@Override
public void computeScroll() {
    Scroller scroller = mFlingScroller;
    if (scroller.isFinished()) {
        scroller = mAdjustScroller;
        if (scroller.isFinished()) {
            return;
        }
    }
    scroller.computeScrollOffset();
    int currentScrollerY = scroller.getCurrY();
    if (mPreviousScrollerY == 0) {
        mPreviousScrollerY = scroller.getStartY();
    }
    scrollBy(0, currentScrollerY - mPreviousScrollerY);
    mPreviousScrollerY = currentScrollerY;
    if (scroller.isFinished()) {
        onScrollerFinished(scroller);
    } else {
        invalidate();
    }
}
 
开发者ID:Gericop,项目名称:DateTimePicker,代码行数:23,代码来源:NumberPicker.java

示例4: run

import android.widget.Scroller; //导入方法依赖的package包/类
public void run() {
    switch (this.this$0.mTouchMode) {
        case 4:
            if (this.this$0.mItemCount == 0 || this.this$0.getChildCount() == 0) {
                endFling();
                return;
            }
            Scroller scroller = this.mScroller;
            boolean more = scroller.computeScrollOffset();
            int y = scroller.getCurrY();
            int delta = this.mLastFlingY - y;
            if (delta > 0) {
                this.this$0.mMotionPosition = this.this$0.mFirstPosition;
                this.this$0.mMotionViewOriginalTop = this.this$0.getScrollChildTop();
                delta = Math.min(((this.this$0.getHeight() - this.this$0.getPaddingBottom())
                        - this.this$0.getPaddingTop()) - 1, delta);
            } else {
                int offsetToLast = this.this$0.getChildCount() - 1;
                this.this$0.mMotionPosition = this.this$0.mFirstPosition + offsetToLast;
                this.this$0.mMotionViewOriginalTop = this.this$0.getScrollChildBottom();
                delta = Math.max(-(((this.this$0.getHeight() - this.this$0.getPaddingBottom()
                ) - this.this$0.getPaddingTop()) - 1), delta);
            }
            boolean atEnd = this.this$0.trackMotionScroll(delta, delta);
            if (!more || atEnd) {
                endFling();
                return;
            }
            this.this$0.invalidate();
            this.mLastFlingY = y;
            this.this$0.post(this);
            return;
        default:
            return;
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:37,代码来源:PLA_AbsListView$FlingRunnable.java

示例5: run

import android.widget.Scroller; //导入方法依赖的package包/类
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();
            final int y = scroller.getCurrY();

            // Flip sign to convert finger direction to list items direction
            // (e.g. finger moving down means list is moving towards the top)
            int delta = mLastFlingY - y;

            // 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();
                mMotionViewOriginalTop = getScrollChildTop();

                // Don't fling more than 1 screen
                // delta = Math.min(getHeight() - mPaddingBottom - mPaddingTop - 1, delta);
                delta = Math.min(getHeight() - getPaddingBottom() - getPaddingTop() - 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();
                mMotionViewOriginalTop = getScrollChildBottom();

                // Don't fling more than 1 screen
                // delta = Math.max(-(getHeight() - mPaddingBottom - mPaddingTop - 1), delta);
                delta = Math.max(-(getHeight() - getPaddingBottom() - getPaddingTop() - 1), delta);
            }

            final boolean atEnd = trackMotionScroll(delta, delta);

            if (more && !atEnd) {
                invalidate();
                mLastFlingY = y;
                post(this);
            } else {
                endFling();
                if (PROFILE_FLINGING) {
                    if (mFlingProfilingStarted) {
                        Debug.stopMethodTracing();
                        mFlingProfilingStarted = false;
                    }
                }
            }
            break;
        }
    }
}
 
开发者ID:Shmilyz,项目名称:Swap,代码行数:64,代码来源:PLA_AbsListView.java


注:本文中的android.widget.Scroller.getCurrY方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。