Example usage for android.support.v4.view ViewCompat OVER_SCROLL_IF_CONTENT_SCROLLS

List of usage examples for android.support.v4.view ViewCompat OVER_SCROLL_IF_CONTENT_SCROLLS

Introduction

In this page you can find the example usage for android.support.v4.view ViewCompat OVER_SCROLL_IF_CONTENT_SCROLLS.

Prototype

int OVER_SCROLL_IF_CONTENT_SCROLLS

To view the source code for android.support.v4.view ViewCompat OVER_SCROLL_IF_CONTENT_SCROLLS.

Click Source Link

Document

Allow a user to over-scroll this view only if the content is large enough to meaningfully scroll, provided it is a view that can scroll.

Usage

From source file:com.peerless2012.twowaynestedscrollview.TwoWayNestedScrollView.java

@Override
public void computeScroll() {
    int measuredHeight = getMeasuredHeight();
    int measuredWidth = getMeasuredHeight();
    if (mScroller.computeScrollOffset()) {
        int oldX = getScrollX();
        int oldY = getScrollY();
        int x = mScroller.getCurrX();
        int y = mScroller.getCurrY();
        if (oldX != x || oldY != y) {
            final int horizontalRange = getHorizontalScrollRange();
            final int verticalRange = getVerticalScrollRange();
            final int overscrollMode = ViewCompat.getOverScrollMode(this);
            final boolean canOverscroll = overscrollMode == ViewCompat.OVER_SCROLL_ALWAYS
                    || (overscrollMode == ViewCompat.OVER_SCROLL_IF_CONTENT_SCROLLS
                            && (verticalRange > 0 || horizontalRange > 0));

            overScrollByCompat(x - oldX, y - oldY, oldX, oldY, horizontalRange, verticalRange, 0, 0, false);

            if (canOverscroll) {
                ensureGlows();/*  w  w w .  j a va  2 s. c  o m*/
                if (y <= 0 && oldY > 0) {
                    mEdgeGlowTop.onAbsorb((int) mScroller.getCurrVelocity());
                } else if (y >= verticalRange && oldY < verticalRange) {
                    mEdgeGlowBottom.onAbsorb((int) mScroller.getCurrVelocity());
                }
                if (x <= 0 && oldX > 0) {
                    mEdgeGlowLeft.onAbsorb((int) mScroller.getCurrVelocity());
                } else if (x >= verticalRange && oldX < horizontalRange) {
                    mEdgeGlowRight.onAbsorb((int) mScroller.getCurrVelocity());
                }
            }
        }
    }
}

From source file:com.chenglong.muscle.ui.LazyViewPager.java

@Override
public void draw(Canvas canvas) {
    super.draw(canvas);
    boolean needsInvalidate = false;
    final int overScrollMode = ViewCompat.getOverScrollMode(this);
    if (overScrollMode == ViewCompat.OVER_SCROLL_ALWAYS
            || (overScrollMode == ViewCompat.OVER_SCROLL_IF_CONTENT_SCROLLS && mAdapter != null
                    && mAdapter.getCount() > 1)) {
        if (!mLeftEdge.isFinished()) {
            final int restoreCount = canvas.save();
            final int height = getHeight() - getPaddingTop() - getPaddingBottom();
            canvas.rotate(270);/*www.ja va2  s  .  c o m*/
            canvas.translate(-height + getPaddingTop(), 0);
            mLeftEdge.setSize(height, getWidth());
            needsInvalidate |= mLeftEdge.draw(canvas);
            canvas.restoreToCount(restoreCount);
        }
        if (!mRightEdge.isFinished()) {
            final int restoreCount = canvas.save();
            final int width = getWidth();
            final int height = getHeight() - getPaddingTop() - getPaddingBottom();
            final int itemCount = mAdapter != null ? mAdapter.getCount() : 1;
            canvas.rotate(90);
            canvas.translate(-getPaddingTop(), -itemCount * (width + mPageMargin) + mPageMargin);
            mRightEdge.setSize(height, width);
            needsInvalidate |= mRightEdge.draw(canvas);
            canvas.restoreToCount(restoreCount);
        }
    } else {
        mLeftEdge.finish();
        mRightEdge.finish();
    }
    if (needsInvalidate) {
        // Keep animating
        invalidate();
    }
}

From source file:beichen.douban.ui.view.LazyViewPager.java

@Override
public void draw(Canvas canvas) {
    super.draw(canvas);
    boolean needsInvalidate = false;

    final int overScrollMode = ViewCompat.getOverScrollMode(this);
    if (overScrollMode == ViewCompat.OVER_SCROLL_ALWAYS
            || (overScrollMode == ViewCompat.OVER_SCROLL_IF_CONTENT_SCROLLS && mAdapter != null
                    && mAdapter.getCount() > 1)) {
        if (!mLeftEdge.isFinished()) {
            final int restoreCount = canvas.save();
            final int height = getHeight() - getPaddingTop() - getPaddingBottom();

            canvas.rotate(270);// w  w  w  .j  a  va2s . c  o  m
            canvas.translate(-height + getPaddingTop(), 0);
            mLeftEdge.setSize(height, getWidth());
            needsInvalidate |= mLeftEdge.draw(canvas);
            canvas.restoreToCount(restoreCount);
        }
        if (!mRightEdge.isFinished()) {
            final int restoreCount = canvas.save();
            final int width = getWidth();
            final int height = getHeight() - getPaddingTop() - getPaddingBottom();
            final int itemCount = mAdapter != null ? mAdapter.getCount() : 1;

            canvas.rotate(90);
            canvas.translate(-getPaddingTop(), -itemCount * (width + mPageMargin) + mPageMargin);
            mRightEdge.setSize(height, width);
            needsInvalidate |= mRightEdge.draw(canvas);
            canvas.restoreToCount(restoreCount);
        }
    } else {
        mLeftEdge.finish();
        mRightEdge.finish();
    }

    if (needsInvalidate) {
        // Keep animating
        invalidate();
    }
}

From source file:org.immopoly.android.widget.ViewPager.java

@Override
public void draw(Canvas canvas) {
    super.draw(canvas);
    boolean needsInvalidate = false;

    final int overScrollMode = ViewCompat.getOverScrollMode(this);
    if (overScrollMode == ViewCompat.OVER_SCROLL_ALWAYS
            || (overScrollMode == ViewCompat.OVER_SCROLL_IF_CONTENT_SCROLLS && mAdapter != null
                    && mAdapter.getCount() > 1)) {
        if (!mLeftEdge.isFinished()) {
            final int restoreCount = canvas.save();
            final int height = getHeight() - getPaddingTop() - getPaddingBottom();

            canvas.rotate(270);//  www .  j a  v a 2  s  . c om
            canvas.translate(-height + getPaddingTop(), 0);
            mLeftEdge.setSize(height, getWidth());
            needsInvalidate |= mLeftEdge.draw(canvas);
            canvas.restoreToCount(restoreCount);
        }
        if (!mRightEdge.isFinished()) {
            final int restoreCount = canvas.save();
            final int width = forcedChildWidth > 0 ? forcedChildWidth : getWidth();
            final int height = getHeight() - getPaddingTop() - getPaddingBottom();
            final int itemCount = mAdapter != null ? mAdapter.getCount() : 1;

            canvas.rotate(90);
            canvas.translate(-getPaddingTop(), -itemCount * (width + mPageMargin) + mPageMargin);
            mRightEdge.setSize(height, width);
            needsInvalidate |= mRightEdge.draw(canvas);
            canvas.restoreToCount(restoreCount);
        }
    } else {
        mLeftEdge.finish();
        mRightEdge.finish();
    }

    if (needsInvalidate) {
        // Keep animating
        invalidate();
    }
}

From source file:com.lanou.mirror.tool.VerticalViewPager.java

@Override
public void draw(Canvas canvas) {
    // XXX //from   ww  w.j  a v a 2 s.  com
    super.draw(canvas);
    boolean needsInvalidate = false;

    final int overScrollMode = ViewCompat.getOverScrollMode(this);
    if (overScrollMode == ViewCompat.OVER_SCROLL_ALWAYS
            || (overScrollMode == ViewCompat.OVER_SCROLL_IF_CONTENT_SCROLLS && mAdapter != null
                    && mAdapter.getCount() > 1)) {
        if (!mTopEdge.isFinished()) {
            final int restoreCount = canvas.save();
            final int width = getWidth() - getPaddingLeft() - getPaddingRight();

            canvas.rotate(270);
            canvas.translate(-width + getPaddingLeft(), 0);
            mTopEdge.setSize(width, getHeight());
            needsInvalidate |= mTopEdge.draw(canvas);
            canvas.restoreToCount(restoreCount);
        } /* end of if */
        if (!mBottomEdge.isFinished()) {
            final int restoreCount = canvas.save();
            final int width = getWidth() - getPaddingLeft() - getPaddingRight();
            final int height = getHeight();
            final int itemCount = mAdapter != null ? mAdapter.getCount() : 1;

            canvas.rotate(180);
            canvas.translate(-width + getPaddingLeft(), -itemCount * (height + mPageMargin) + mPageMargin);
            mBottomEdge.setSize(width, height);
            needsInvalidate |= mBottomEdge.draw(canvas);
            canvas.restoreToCount(restoreCount);
        } /* end of if */
    } else {
        mTopEdge.finish();
        mBottomEdge.finish();
    } /* end of if */

    if (needsInvalidate) {
        // Keep animating
        invalidate();
    } /* end of if */
}

From source file:administrator.example.com.myscrollview.VerticalViewPager.java

@Override
public void draw(Canvas canvas) {
    // XXX ?//from w w  w  . jav  a  2  s  .c  o  m
    super.draw(canvas);
    boolean needsInvalidate = false;

    final int overScrollMode = ViewCompat.getOverScrollMode(this);
    if (overScrollMode == ViewCompat.OVER_SCROLL_ALWAYS
            || (overScrollMode == ViewCompat.OVER_SCROLL_IF_CONTENT_SCROLLS && mAdapter != null
                    && mAdapter.getCount() > 1)) {
        if (!mTopEdge.isFinished()) {
            final int restoreCount = canvas.save();
            final int width = getWidth() - getPaddingLeft() - getPaddingRight();

            canvas.rotate(270);
            canvas.translate(-width + getPaddingLeft(), 0);
            mTopEdge.setSize(width, getHeight());
            needsInvalidate |= mTopEdge.draw(canvas);
            canvas.restoreToCount(restoreCount);
        } /* end of if */
        if (!mBottomEdge.isFinished()) {
            final int restoreCount = canvas.save();
            final int width = getWidth() - getPaddingLeft() - getPaddingRight();
            final int height = getHeight();
            final int itemCount = mAdapter != null ? mAdapter.getCount() : 1;

            canvas.rotate(180);
            canvas.translate(-width + getPaddingLeft(), -itemCount * (height + mPageMargin) + mPageMargin);
            mBottomEdge.setSize(width, height);
            needsInvalidate |= mBottomEdge.draw(canvas);
            canvas.restoreToCount(restoreCount);
        } /* end of if */
    } else {
        mTopEdge.finish();
        mBottomEdge.finish();
    } /* end of if */

    if (needsInvalidate) {
        // Keep animating
        invalidate();
    } /* end of if */
}

From source file:com.bluetoothlamp.tiny.view.verticalview.VerticalViewPager.java

@Override
public void draw(Canvas canvas) {
    // XXX ??/*w  w w .ja  v  a 2  s . c  o m*/
    super.draw(canvas);
    boolean needsInvalidate = false;

    final int overScrollMode = ViewCompat.getOverScrollMode(this);
    if (overScrollMode == ViewCompat.OVER_SCROLL_ALWAYS
            || (overScrollMode == ViewCompat.OVER_SCROLL_IF_CONTENT_SCROLLS && mAdapter != null
                    && mAdapter.getCount() > 1)) {
        if (!mTopEdge.isFinished()) {
            final int restoreCount = canvas.save();
            final int width = getWidth() - getPaddingLeft() - getPaddingRight();

            canvas.rotate(270);
            canvas.translate(-width + getPaddingLeft(), 0);
            mTopEdge.setSize(width, getHeight());
            needsInvalidate |= mTopEdge.draw(canvas);
            canvas.restoreToCount(restoreCount);
        } /* end of if */
        if (!mBottomEdge.isFinished()) {
            final int restoreCount = canvas.save();
            final int width = getWidth() - getPaddingLeft() - getPaddingRight();
            final int height = getHeight();
            final int itemCount = mAdapter != null ? mAdapter.getCount() : 1;

            canvas.rotate(180);
            canvas.translate(-width + getPaddingLeft(), -itemCount * (height + mPageMargin) + mPageMargin);
            mBottomEdge.setSize(width, height);
            needsInvalidate |= mBottomEdge.draw(canvas);
            canvas.restoreToCount(restoreCount);
        } /* end of if */
    } else {
        mTopEdge.finish();
        mBottomEdge.finish();
    } /* end of if */

    if (needsInvalidate) {
        // Keep animating
        invalidate();
    } /* end of if */
}

From source file:javalibrary.android.ui.VerticalViewPager.java

@Override
public void draw(Canvas canvas) {
    super.draw(canvas);
    boolean needsInvalidate = false;
    if (DEBUG)/*from w w w .j  ava2 s .  c o  m*/
        Log.v(TAG, "draw");
    final int overScrollMode = ViewCompat.getOverScrollMode(this);
    if (overScrollMode == ViewCompat.OVER_SCROLL_ALWAYS
            || (overScrollMode == ViewCompat.OVER_SCROLL_IF_CONTENT_SCROLLS && mAdapter != null
                    && mAdapter.getCount() > 1)) {
        /*if (!mLeftEdge.isFinished()) {
        final int restoreCount = canvas.save();
        final int height = getHeight() - getPaddingTop() - getPaddingBottom();
                
        canvas.rotate(270);
        canvas.translate(-height + getPaddingTop(), 0);
        mLeftEdge.setSize(height, getWidth());
        needsInvalidate |= mLeftEdge.draw(canvas);
        canvas.restoreToCount(restoreCount);
        }
        if (!mRightEdge.isFinished()) {
        final int restoreCount = canvas.save();
        final int width = getWidth();
        final int height = getHeight() - getPaddingTop() - getPaddingBottom();
        final int itemCount = mAdapter != null ? mAdapter.getCount() : 1;
                
        canvas.rotate(90);
        canvas.translate(-getPaddingTop(),
                -itemCount * (width + mPageMargin) + mPageMargin);
        mRightEdge.setSize(height, width);
        needsInvalidate |= mRightEdge.draw(canvas);
        canvas.restoreToCount(restoreCount);
        }*/
        if (!mTopEdge.isFinished()) {
            final int restoreCount = canvas.save();
            final int height = getHeight() - getPaddingTop() - getPaddingBottom();

            canvas.rotate(270);
            canvas.translate(-height + getPaddingTop(), 0);
            mTopEdge.setSize(height, getWidth());
            needsInvalidate |= mTopEdge.draw(canvas);
            canvas.restoreToCount(restoreCount);
        }
        if (!mBottomEdge.isFinished()) {
            final int restoreCount = canvas.save();
            final int width = getWidth();
            final int height = getHeight() - getPaddingTop() - getPaddingBottom();
            final int itemCount = mAdapter != null ? mAdapter.getCount() : 1;

            canvas.rotate(90);
            canvas.translate(-getPaddingTop(), -itemCount * (width + mPageMargin) + mPageMargin);
            mBottomEdge.setSize(height, width);
            needsInvalidate |= mBottomEdge.draw(canvas);
            canvas.restoreToCount(restoreCount);
        }
    } else {
        mLeftEdge.finish();
        mRightEdge.finish();
        mTopEdge.finish();
        mBottomEdge.finish();
    }

    if (needsInvalidate) {
        // Keep animating
        invalidate();
    }
}

From source file:com.example.view.VerticalViewPager.java

@Override
public void draw(Canvas canvas) {
    // XXX/*from  w ww .  j  av  a2 s  . c o  m*/
    super.draw(canvas);
    boolean needsInvalidate = false;

    final int overScrollMode = ViewCompat.getOverScrollMode(this);
    if (overScrollMode == ViewCompat.OVER_SCROLL_ALWAYS
            || (overScrollMode == ViewCompat.OVER_SCROLL_IF_CONTENT_SCROLLS && mAdapter != null
                    && mAdapter.getCount() > 1)) {
        if (!mTopEdge.isFinished()) {
            final int restoreCount = canvas.save();
            final int width = getWidth() - getPaddingLeft() - getPaddingRight();

            canvas.rotate(270);
            canvas.translate(-width + getPaddingLeft(), 0);
            mTopEdge.setSize(width, getHeight());
            needsInvalidate |= mTopEdge.draw(canvas);
            canvas.restoreToCount(restoreCount);
        } /* end of if */
        if (!mBottomEdge.isFinished()) {
            final int restoreCount = canvas.save();
            final int width = getWidth() - getPaddingLeft() - getPaddingRight();
            final int height = getHeight();
            final int itemCount = mAdapter != null ? mAdapter.getCount() : 1;

            canvas.rotate(180);
            canvas.translate(-width + getPaddingLeft(), -itemCount * (height + mPageMargin) + mPageMargin);
            mBottomEdge.setSize(width, height);
            needsInvalidate |= mBottomEdge.draw(canvas);
            canvas.restoreToCount(restoreCount);
        } /* end of if */
    } else {
        mTopEdge.finish();
        mBottomEdge.finish();
    } /* end of if */

    if (needsInvalidate) {
        // Keep animating
        invalidate();
    } /* end of if */
}

From source file:interactive.view.pagereader.VerticalViewPager.java

@Override
public void draw(Canvas canvas) {
    // XXX ?/* w ww  . j a va  2s .c o m*/
    super.draw(canvas);
    boolean needsInvalidate = false;

    final int overScrollMode = ViewCompat.getOverScrollMode(this);
    if (overScrollMode == ViewCompat.OVER_SCROLL_ALWAYS
            || (overScrollMode == ViewCompat.OVER_SCROLL_IF_CONTENT_SCROLLS && mAdapter != null
                    && mAdapter.getCount() > 1)) {
        if (!mTopEdge.isFinished()) {
            final int restoreCount = canvas.save();
            final int width = getWidth() - getPaddingLeft() - getPaddingRight();

            canvas.rotate(270);
            canvas.translate(-width + getPaddingLeft(), 0);
            mTopEdge.setSize(width, getHeight());
            needsInvalidate |= mTopEdge.draw(canvas);
            canvas.restoreToCount(restoreCount);
        } /* end of if */
        if (!mBottomEdge.isFinished()) {
            final int restoreCount = canvas.save();
            final int width = getWidth() - getPaddingLeft() - getPaddingRight();
            final int height = getHeight();
            final int itemCount = mAdapter != null ? mAdapter.getCount() : 1;

            canvas.rotate(180);
            canvas.translate(-width + getPaddingLeft(), -itemCount * (height + mPageMargin) + mPageMargin);
            mBottomEdge.setSize(width, height);
            needsInvalidate |= mBottomEdge.draw(canvas);
            canvas.restoreToCount(restoreCount);
        } /* end of if */
    } else {
        mTopEdge.finish();
        mBottomEdge.finish();
    } /* end of if */

    if (needsInvalidate) {
        // Keep animating
        invalidate();
    } /* end of if */
}