當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。