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


Java EdgeEffectCompat.onAbsorb方法代碼示例

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


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

示例1: computeScroll

import android.support.v4.widget.EdgeEffectCompat; //導入方法依賴的package包/類
@Override
public void computeScroll() {
    if (mScroller.computeScrollOffset()) {
        final int y = mScroller.getCurrY();
        final int dy = (int) (y - mLastTouchY);
        mLastTouchY = y;
        final boolean stopped = !trackMotionScroll(dy, false);

        if (!stopped && !mScroller.isFinished()) {
            postInvalidate();
        } else {
            if (stopped) {
                final int overScrollMode = ViewCompat.getOverScrollMode(this);
                if (overScrollMode != ViewCompat.OVER_SCROLL_NEVER) {
                    final EdgeEffectCompat edge;
                    if (dy > 0) {
                        edge = mTopEdge;
                    } else {
                        edge = mBottomEdge;
                    }
                    edge.onAbsorb(Math.abs((int) mScroller.getCurrVelocity()));
                    postInvalidate();
                }
                mScroller.abortAnimation();

            }
            mTouchMode = TOUCH_MODE_IDLE;
        }
    }
}
 
開發者ID:SNiels,項目名稱:Multi-Mania-app,代碼行數:31,代碼來源:BulletStaggeredGridView.java

示例2: computeScroll

import android.support.v4.widget.EdgeEffectCompat; //導入方法依賴的package包/類
public void computeScroll() {
    if (mScroller.computeScrollOffset()) {
        final int y = mScroller.getCurrY();
        final int dy = (int) (y - mLastTouchY);
        mLastTouchY = y;
        final boolean stopped = !trackMotionScroll(dy, false);
        if (!stopped && !mScroller.isFinished()) {
            ViewCompat.postInvalidateOnAnimation(this);
        } else {
            if (stopped) {
                final int overScrollMode = ViewCompat.getOverScrollMode(this);
                if (overScrollMode != ViewCompat.OVER_SCROLL_NEVER) {
                    final EdgeEffectCompat edge;
                    if (dy > 0) {
                        edge = mTopEdge;
                    } else {
                        edge = mBottomEdge;
                    }
                    edge.onAbsorb(Math.abs((int) mScroller.getCurrVelocity()));
                    ViewCompat.postInvalidateOnAnimation(this);
                }
                mScroller.abortAnimation();
            }
            mTouchMode = TOUCH_MODE_IDLE;
        }
    }
}
 
開發者ID:SNiels,項目名稱:Multi-Mania-app,代碼行數:28,代碼來源:StaggeredGridView.java

示例3: computeScroll

import android.support.v4.widget.EdgeEffectCompat; //導入方法依賴的package包/類
@Override
public void computeScroll() {
    if (mScroller.computeScrollOffset()) {
        final int x = mScroller.getCurrX();
        final int dx = (int) (x - mLastTouchX);
        mLastTouchX = x;
        final boolean stopped = !trackMotionScroll(dx, false);

        if (!stopped && !mScroller.isFinished()) {
            ViewCompat.postInvalidateOnAnimation(this);
        } else {
            if (stopped) {
                final int overScrollMode = ViewCompat.getOverScrollMode(this);
                if (overScrollMode != ViewCompat.OVER_SCROLL_NEVER) {
                    final EdgeEffectCompat edge;
                    if (dx > 0) {
                        edge = mLeftEdge;
                    } else {
                        edge = mRightEdge;
                    }
                    edge.onAbsorb(Math.abs((int) mScroller.getCurrVelocity()));
                    ViewCompat.postInvalidateOnAnimation(this);
                }
                mScroller.abortAnimation();
            }
            mTouchMode = TOUCH_MODE_IDLE;
        }
    }
}
 
開發者ID:asm-products,項目名稱:nexus-gallery,代碼行數:30,代碼來源:GalleryThumbnailView.java

示例4: computeScroll

import android.support.v4.widget.EdgeEffectCompat; //導入方法依賴的package包/類
public void computeScroll() {
    if (mScroller.computeScrollOffset()) {
        final int y = mScroller.getCurrY();
        final int dy = (int) (y - mLastTouchY);
        mLastTouchY = y;
        final boolean stopped = !trackMotionScroll(dy, false);

        if (!stopped && !mScroller.isFinished()) {
            postInvalidate();
        } else {
            if (stopped) {
                final int overScrollMode = ViewCompat.getOverScrollMode(this);
                if (overScrollMode != ViewCompat.OVER_SCROLL_NEVER) {
                    final EdgeEffectCompat edge;
                    if (dy > 0) {
                        edge = mTopEdge;
                    } else {
                        edge = mBottomEdge;
                    }
                    edge.onAbsorb(Math.abs((int) mScroller.getCurrVelocity()));
                    postInvalidate();
                }
                mScroller.abortAnimation();
            }
            mTouchMode = TOUCH_MODE_IDLE;
        }
    }
}
 
開發者ID:GMAndroidTeam,項目名稱:Android-PullToRefresh,代碼行數:29,代碼來源:StaggeredGridView.java

示例5: computeScroll

import android.support.v4.widget.EdgeEffectCompat; //導入方法依賴的package包/類
public void computeScroll()
{
    if (mScroller.computeScrollOffset())
    {
        final int y = mScroller.getCurrY();
        final int dy = (int) (y - mLastTouchY);
        mLastTouchY = y;
        final boolean stopped = !trackMotionScroll(dy, false);

        if (!stopped && !mScroller.isFinished())
        {
            postInvalidate();
        }
        else
        {
            if (stopped)
            {
                final int overScrollMode = ViewCompat.getOverScrollMode(this);
                if (overScrollMode != ViewCompat.OVER_SCROLL_NEVER)
                {
                    final EdgeEffectCompat edge;
                    if (dy > 0)
                    {
                        edge = mTopEdge;
                    }
                    else
                    {
                        edge = mBottomEdge;
                    }
                    edge.onAbsorb(Math.abs((int) mScroller.getCurrVelocity()));
                    postInvalidate();
                }
                mScroller.abortAnimation();
            }
            mTouchMode = TOUCH_MODE_IDLE;
        }
    }
}
 
開發者ID:kimkha,項目名稱:Finanvita,代碼行數:39,代碼來源:StaggeredGridView.java

示例6: computeScroll

import android.support.v4.widget.EdgeEffectCompat; //導入方法依賴的package包/類
@Override
public void computeScroll() {
    if (!mScroller.computeScrollOffset()) {
        return;
    }

    final int pos;
    if (mIsVertical) {
        pos = mScroller.getCurrY();
    } else {
        pos = mScroller.getCurrX();
    }

    final int diff = (int) (pos - mLastTouchPos);
    mLastTouchPos = pos;

    final boolean stopped = scrollListItemsBy(diff);

    if (!stopped && !mScroller.isFinished()) {
        ViewCompat.postInvalidateOnAnimation(this);
    } else {
        if (stopped) {
            final int overScrollMode = ViewCompat.getOverScrollMode(this);
            if (overScrollMode != ViewCompat.OVER_SCROLL_NEVER) {
                final EdgeEffectCompat edge =
                        (diff > 0 ? mStartEdge : mEndEdge);

                boolean needsInvalidate =
                        edge.onAbsorb(Math.abs((int) getCurrVelocity()));

                if (needsInvalidate) {
                    ViewCompat.postInvalidateOnAnimation(this);
                }
            }

            finishSmoothScrolling();
        }

        mTouchMode = TOUCH_MODE_REST;
        reportScrollStateChange(OnScrollListener.SCROLL_STATE_IDLE);
    }
}
 
開發者ID:melvinjlobo,項目名稱:WebStarter,代碼行數:43,代碼來源:TwoWayView.java

示例7: computeScroll

import android.support.v4.widget.EdgeEffectCompat; //導入方法依賴的package包/類
@Override
public void computeScroll()
{
    if ( !mScroller.computeScrollOffset() )
    {
        return;
    }

    final int pos;
    if ( mIsVertical )
    {
        pos = mScroller.getCurrY();
    }
    else
    {
        pos = mScroller.getCurrX();
    }

    final int diff = ( int ) ( pos - mLastTouchPos );
    mLastTouchPos = pos;

    final boolean stopped = scrollListItemsBy( diff );

    if ( !stopped && !mScroller.isFinished() )
    {
        ViewCompat.postInvalidateOnAnimation( this );
    }
    else
    {
        if ( stopped )
        {
            final int overScrollMode = ViewCompat.getOverScrollMode( this );
            if ( overScrollMode != ViewCompat.OVER_SCROLL_NEVER )
            {
                final EdgeEffectCompat edge =
                        ( diff > 0 ? mStartEdge : mEndEdge );

                boolean needsInvalidate =
                        edge.onAbsorb( Math.abs( ( int ) getCurrVelocity() ) );

                if ( needsInvalidate )
                {
                    ViewCompat.postInvalidateOnAnimation( this );
                }
            }

            mScroller.abortAnimation();
        }

        mTouchMode = TOUCH_MODE_REST;
        reportScrollStateChange( OnScrollListener.SCROLL_STATE_IDLE );
    }
}
 
開發者ID:iTwenty,項目名稱:Hashtagger,代碼行數:54,代碼來源:TwoWayView.java

示例8: computeScroll

import android.support.v4.widget.EdgeEffectCompat; //導入方法依賴的package包/類
@Override
public void computeScroll() {
    if (!mScroller.computeScrollOffset()) {
        return;
    }

    final int pos;
    if (mIsVertical) {
        pos = mScroller.getCurrY();
    } else {
        pos = mScroller.getCurrX();
    }

    final int diff = (int) (pos - mLastTouchPos);
    mLastTouchPos = pos;

    final boolean stopped = scrollListItemsBy(diff);

    if (!stopped && !mScroller.isFinished()) {
        ViewCompat.postInvalidateOnAnimation(this);
    } else {
        if (stopped) {
            final int overScrollMode = ViewCompat.getOverScrollMode(this);
            if (overScrollMode != ViewCompat.OVER_SCROLL_NEVER) {
                final EdgeEffectCompat edge =
                        (diff > 0 ? mStartEdge : mEndEdge);

                boolean needsInvalidate =
                        edge.onAbsorb(Math.abs((int) getCurrVelocity()));

                if (needsInvalidate) {
                    ViewCompat.postInvalidateOnAnimation(this);
                }
            }

            mScroller.abortAnimation();
        }

        mTouchMode = TOUCH_MODE_REST;
        reportScrollStateChange(OnScrollListener.SCROLL_STATE_IDLE);
    }
}
 
開發者ID:xiaoma1219,項目名稱:netkuu.player,代碼行數:43,代碼來源:TwoWayView.java

示例9: computeScroll

import android.support.v4.widget.EdgeEffectCompat; //導入方法依賴的package包/類
@Override
public void computeScroll() {
    if (mTouchMode == TOUCH_MODE_OVERFLING) {
        handleOverfling();
    } else if (mScroller.computeScrollOffset()) {
        final int overScrollMode = ViewCompat.getOverScrollMode(this);
        final boolean supportsOverscroll = overScrollMode != ViewCompat.OVER_SCROLL_NEVER;
        final int y = mScroller.getCurrY();
        final int dy = (int) (y - mLastTouchY);
        // TODO: Figure out why mLastTouchY is being updated here. Consider using a new class
        // variable since this value does not represent the last place on the screen where a
        // touch occurred.
        mLastTouchY = y;
        // Check if the top of the motion view is where it is
        // supposed to be
        final View motionView = supportsOverscroll &&
                getChildCount() > 0 ? getChildAt(0) : null;
        final int motionViewPrevTop = motionView != null ? motionView.getTop() : 0;
        final boolean stopped = !trackMotionScroll(dy, false);
        if (!stopped && !mScroller.isFinished()) {
            mTouchMode = TOUCH_MODE_IDLE;
            ViewCompat.postInvalidateOnAnimation(this);
        } else if (stopped && dy != 0 && supportsOverscroll) {
                // Check to see if we have bumped into the scroll limit
                if (motionView != null) {
                    final int motionViewRealTop = motionView.getTop();
                    // Apply overscroll
                    final int overscroll = -dy - (motionViewRealTop - motionViewPrevTop);
                    overScrollBy(0, overscroll, 0, getScrollY(), 0, 0, 0, mOverscrollDistance,
                            true);
                }
                final EdgeEffectCompat edge;
                if (dy > 0) {
                    edge = mTopEdge;
                    mBottomEdge.finish();
                } else {
                    edge = mBottomEdge;
                    mTopEdge.finish();
                }
                edge.onAbsorb(Math.abs((int) mScroller.getCurrVelocity()));
                if (mScroller.computeScrollOffset()) {
                    mScroller.notifyVerticalEdgeReached(getScrollY(), 0, mOverscrollDistance);
                }
                mTouchMode = TOUCH_MODE_OVERFLING;
                ViewCompat.postInvalidateOnAnimation(this);
        } else {
            mTouchMode = TOUCH_MODE_IDLE;
        }
    }
}
 
開發者ID:ocae,項目名稱:countdown,代碼行數:51,代碼來源:StaggeredGridView.java


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