Android OverScroller - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android OverScroller class.

This code example shows how to use the following methods:computeScrollOffset, getCurrX, getCurrY
		} 
	}; 
	 
	@Override 
	public void computeScroll() { 
        if (mScroller.computeScrollOffset()) {
            // This is called at drawing time by ViewGroup.  We use 
            // this method to keep the fling animation going through 
            // to completion. 
            int oldX = getScrollX();
            int oldY = getScrollY();
            int x = mScroller.getCurrX();
            int y = mScroller.getCurrY();
 
            if (getChildCount() > 0) {
                View child = getChildAt(0);
                x = clamp(x, getWidth() - getPaddingRight() - getPaddingLeft(), child.getWidth());
                y = clamp(y, getHeight() - getPaddingBottom() - getPaddingTop(), child.getHeight());
                if (x != oldX || y != oldY) {
                    scrollTo(x, y);
6
CodeRank
This code example shows how to use the following methods:computeScrollOffset, getCurrX, getCurrY
        child.measure(childWidthMeasureSpec, childHeightMeasureSpec);
    } 
	 
	@Override 
	public void computeScroll() { 
        if (mScroller.computeScrollOffset()) {
            // This is called at drawing time by ViewGroup.  We use 
            // this method to keep the fling animation going through 
            // to completion. 
            int oldX = getScrollX();
            int oldY = getScrollY();
            int x = mScroller.getCurrX();
            int y = mScroller.getCurrY();
 
            if (getChildCount() > 0) {
                View child = getChildAt(0);
                x = clamp(x, getWidth() - getPaddingRight() - getPaddingLeft(), child.getWidth());
                y = clamp(y, getHeight() - getPaddingBottom() - getPaddingTop(), child.getHeight());
                if (x != oldX || y != oldY) {
                    scrollTo(x, y);
6
CodeRank
This code example shows how to use the following methods:getCurrX, getFinalX, startScroll
                mOverflingEnabled ? mOverflingDistance : 0, 0);
    } 
 
    // Returns the distance that over the scroll limit. 
    public int startScroll(int distance, int min, int max) {
        int currPosition = mScroller.getCurrX();
        int finalPosition = mScroller.getFinalX();
        int newPosition = Utils.clamp(finalPosition + distance, min, max);
        if (newPosition != currPosition) {
            mScroller.startScroll(
                currPosition, 0,                    // startX, startY
                newPosition - currPosition, 0, 0);  // dx, dy, duration
        } 
        return finalPosition + distance - newPosition;
    } 
} 
6
CodeRank
This code example shows how to use the following methods:getFinalX, getFinalY, getStartX, getStartY, isFinished
    } 
     
    // from OverScroller.java 
     
    static public boolean isScrollingInDirection(OverScroller scroller, float xvel, float yvel) {
        final int dx = scroller.getFinalX() - scroller.getStartX();
        final int dy = scroller.getFinalY() - scroller.getStartY();
        return !scroller.isFinished() && Math.signum(xvel) == Math.signum(dx) &&
                Math.signum(yvel) == Math.signum(dy);
    } 
} 
6
CodeRank
This code example shows how to use the following methods:getCurrVelocity
     * @see android.view.ScaleGestureDetector#getCurrentSpanY() 
     */ 
    @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
    public static float getCurrVelocity(OverScroller overScroller) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
            return overScroller.getCurrVelocity();
        } else { 
            return 0; 
        } 
    } 
} 
6
CodeRank
This code example shows how to use the following methods:computeScrollOffset
		mScroller.startScroll( initialX, 0, distance, 0, mAnimationDuration );
	} 
 
	@Override 
	protected boolean computeScrollOffset() { 
		return mScroller.computeScrollOffset();
	} 
 
	@Override 
	protected int getCurrX() { 
		return mScroller.getCurrX();
	} 
 
	@Override 
	protected void forceFinished( boolean finished ) {
		mScroller.abortAnimation();
	} 
} 
6
CodeRank
This code example shows how to use the following methods:getCurrVelocity
     * @see android.view.ScaleGestureDetector#getCurrentSpanY() 
     */ 
    @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
    public static float getCurrVelocity(OverScroller overScroller) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
            return overScroller.getCurrVelocity();
        } else { 
            return 0; 
        } 
    } 
} 
6
CodeRank
This code example shows how to use the following methods:getCurrX, getFinalX, startScroll
                mOverflingEnabled ? mOverflingDistance : 0, 0);
    } 
 
    // Returns the distance that over the scroll limit. 
    public int startScroll(int distance, int min, int max) {
        int currPosition = mScroller.getCurrX();
        int finalPosition = mScroller.getFinalX();
        int newPosition = Utils.clamp(finalPosition + distance, min, max);
        if (newPosition != currPosition) {
            mScroller.startScroll(
                currPosition, 0,                    // startX, startY
                newPosition - currPosition, 0, 0);  // dx, dy, duration
        } 
        return finalPosition + distance - newPosition;
    } 
} 
5
CodeRank
This code example shows how to use the following methods:computeScrollOffset, getCurrVelocity, getCurrX, getCurrY
        mDelegate.invalidate();
    } 
 
    // Called immediately before the draw to update the scroll offset. 
    public void computeScrollAndAbsorbGlow(OverScrollGlow overScrollGlow) {
        final boolean stillAnimating = mScroller.computeScrollOffset();
        if (!stillAnimating) return;
 
        final int oldX = mDelegate.getContainerViewScrollX();
        final int oldY = mDelegate.getContainerViewScrollY();
        int x = mScroller.getCurrX();
        int y = mScroller.getCurrY();
 
        int rangeX = computeMaximumHorizontalScrollOffset();
        int rangeY = computeMaximumVerticalScrollOffset();
 
        if (overScrollGlow != null) {
            overScrollGlow.absorbGlow(x, y, oldX, oldY, rangeX, rangeY,
                    mScroller.getCurrVelocity());
        } 

5
CodeRank
This code example shows how to use the following methods:getCurrVelocity
	} 
 
	@TargetApi(14) 
	@Override 
	public float getCurrVelocity() { 
		return mScroller.getCurrVelocity();
	} 
 
	@Override 
	public boolean isFinished() { 
		return mScroller.isFinished();
	} 
 
	@Override 
	public boolean springBack( int startX, int startY, int minX, int maxX, int minY, int maxY ) {
		return mScroller.springBack( startX, startY, minX, maxX, minY, maxY );
	} 
 
	@Override 
	protected void _startUsingVelocity( int initialX, int velocity ) {
5
CodeRank

Related Android OverScroller Questions & Answers:

See Code Examples for Android OverScroller Methods: