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

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

Introduction

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

Prototype

public static int getOverScrollMode(View v) 

Source Link

Document

Returns the over-scroll mode for this view.

Usage

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  a  va 2 s . c om
        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/*  w ww .j  ava  2s  . c om*/
    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 ?/*from   www.  ja  va 2s  .c  om*/
    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.peerless2012.twowaynestedscrollview.TwoWayNestedScrollView.java

private void ensureGlows() {
    if (ViewCompat.getOverScrollMode(this) != ViewCompat.OVER_SCROLL_NEVER) {
        if (mEdgeGlowTop == null) {
            Context context = getContext();
            mEdgeGlowTop = new EdgeEffectCompat(context);
            mEdgeGlowBottom = new EdgeEffectCompat(context);
            mEdgeGlowLeft = new EdgeEffectCompat(context);
            mEdgeGlowRight = new EdgeEffectCompat(context);
        }/*from w w w. jav  a  2  s.  co  m*/
    } else {
        mEdgeGlowTop = null;
        mEdgeGlowBottom = null;
        mEdgeGlowLeft = null;
        mEdgeGlowRight = null;
    }
}

From source file:com.gome.ecmall.custom.VerticalViewPager.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 (!mTopEdge.isFinished()) {
            final int restoreCount = canvas.save();
            final int width = getWidth() - getPaddingLeft() - getPaddingRight();
            final int height = getHeight();
            canvas.rotate(270);/*from www .  j a  v  a  2 s. c  o  m*/
            canvas.translate(mFirstOffset * height, -width + getPaddingLeft());

            mTopEdge.setSize(width, height);
            needsInvalidate |= mTopEdge.draw(canvas);
            canvas.restoreToCount(restoreCount);
        }
        if (!mBottomEdge.isFinished()) {
            final int restoreCount = canvas.save();
            final int width = getWidth() - getPaddingLeft() - getPaddingRight();
            final int height = getHeight();

            canvas.rotate(90);
            canvas.translate(-(mLastOffset + 1) * height, -getPaddingLeft());
            mBottomEdge.setSize(width, height);
            needsInvalidate |= mBottomEdge.draw(canvas);
            canvas.restoreToCount(restoreCount);
        }
    } else {
        mTopEdge.finish();
        mBottomEdge.finish();
    }

    if (needsInvalidate) {
        // Keep animating
        ViewCompat.postInvalidateOnAnimation(this);
    }
}

From source file:android.support.v71.widget.RecyclerView.java

/**
 * Does not perform bounds checking. Used by internal methods that have already validated input.
 * <p/>/*from w w w .  ja va 2s  .  c om*/
 * It also reports any unused scroll request to the related EdgeEffect.
 *
 * @param x  The amount of horizontal scroll request
 * @param y  The amount of vertical scroll request
 * @param ev The originating MotionEvent, or null if not from a touch event.
 * @return Whether any scroll was consumed in either direction.
 */
boolean scrollByInternal(int x, int y, MotionEvent ev) {
    int unconsumedX = 0, unconsumedY = 0;
    int consumedX = 0, consumedY = 0;

    consumePendingUpdateOperations();
    if (mAdapter != null) {
        eatRequestLayout();
        onEnterLayoutOrScroll();
        TraceCompat.beginSection(TRACE_SCROLL_TAG);
        if (x != 0) {
            consumedX = mLayout.scrollHorizontallyBy(x, mRecycler, mState);
            unconsumedX = x - consumedX;
        }
        if (y != 0) {
            consumedY = mLayout.scrollVerticallyBy(y, mRecycler, mState);
            unconsumedY = y - consumedY;
        }
        TraceCompat.endSection();
        repositionShadowingViews();
        onExitLayoutOrScroll();
        resumeRequestLayout(false);
    }
    if (!mItemDecorations.isEmpty()) {
        invalidate();
    }

    if (dispatchNestedScroll(consumedX, consumedY, unconsumedX, unconsumedY, mScrollOffset)) {
        // Update the last touch co-ords, taking any scroll offset into account
        mLastTouchX -= mScrollOffset[0];
        mLastTouchY -= mScrollOffset[1];
        if (ev != null) {
            ev.offsetLocation(mScrollOffset[0], mScrollOffset[1]);
        }
        mNestedOffsets[0] += mScrollOffset[0];
        mNestedOffsets[1] += mScrollOffset[1];
    } else if (ViewCompat.getOverScrollMode(this) != ViewCompat.OVER_SCROLL_NEVER) {
        if (ev != null) {
            pullGlows(ev.getX(), unconsumedX, ev.getY(), unconsumedY);
        }
        considerReleasingGlowsOnScroll(x, y);
    }
    if (consumedX != 0 || consumedY != 0) {
        dispatchOnScrolled(consumedX, consumedY);
    }
    if (!awakenScrollBars()) {
        invalidate();
    }
    return consumedX != 0 || consumedY != 0;
}

From source file:com.brantapps.viewpagerindicator.vertical.VerticalViewPager.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)) {
        // BrantApps Change: Various, including the rotation and translation of the edges, padding applied to width not height
        // BrantApps Change: Was:
        /*/*from  www. jav a  2s.  c  o m*/
        if (!mLeftEdge.isFinished()) {
        final int restoreCount = canvas.save();
        final int height = getHeight() - getPaddingTop() - getPaddingBottom();
        final int width = getWidth();
                
        canvas.rotate(270);
        canvas.translate(-height + getPaddingTop(), mFirstOffset * width);
        mLeftEdge.setSize(height, width);
        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();
                
        canvas.rotate(90);
        canvas.translate(-getPaddingTop(), -(mLastOffset + 1) * width);
        mRightEdge.setSize(height, width);
        needsInvalidate |= mRightEdge.draw(canvas);
        canvas.restoreToCount(restoreCount);
        }
         */
        if (!mTopEdge.isFinished()) {
            final int restoreCount = canvas.save();
            final int width = getWidth() - getPaddingLeft() - getPaddingRight();
            final int height = getHeight();

            canvas.translate(-getPaddingLeft(), mFirstOffset * height);
            mTopEdge.setSize(width, height);
            needsInvalidate |= mTopEdge.draw(canvas);
            canvas.restoreToCount(restoreCount);
        }
        if (!mBottomEdge.isFinished()) {
            final int restoreCount = canvas.save();
            final int width = getWidth() - getPaddingLeft() - getPaddingRight();
            final int height = getHeight();

            canvas.rotate(180);
            canvas.translate(-width + getPaddingLeft(), -(mLastOffset + 1) * height);
            mBottomEdge.setSize(width, height);
            needsInvalidate |= mBottomEdge.draw(canvas);
            canvas.restoreToCount(restoreCount);
        }
    } else {
        mTopEdge.finish();
        mBottomEdge.finish();
    }

    if (needsInvalidate) {
        // Keep animating
        ViewCompat.postInvalidateOnAnimation(this);
    }
}

From source file:com.dian.diabetes.widget.VerticalViewPager.java

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

    //jelle disabled edge effect
    final int overScrollMode = ViewCompat.getOverScrollMode(this);
    if (overScrollMode == ViewCompat.OVER_SCROLL_ALWAYS
            || (overScrollMode == ViewCompat.OVER_SCROLL_IF_CONTENT_SCROLLS && mAdapter != null
                    && mAdapter.getCount() > 1)) {

        final int height = getHeight();
        final int width = getWidth() - getPaddingLeft() - getPaddingRight();

        if (!mTopEdge.isFinished()) {
            mTopEdge.setSize(width, height);
            needsInvalidate |= mTopEdge.draw(canvas);
        }/*  w  w w. j av  a  2s. co  m*/
        if (!mBottomEdge.isFinished()) {
            final int restoreCount = canvas.save();
            canvas.translate(-width + getPaddingLeft(), getScrollY() + height);
            canvas.rotate(180, width, 0);
            mBottomEdge.setSize(width, height);

            needsInvalidate |= mBottomEdge.draw(canvas);

            canvas.restoreToCount(restoreCount);
        }
    } else {
        mTopEdge.finish();
        mBottomEdge.finish();
    }

    if (needsInvalidate) {
        // Keep animating
        ViewCompat.postInvalidateOnAnimation(this);
    }
}

From source file:com.hainva.feedlynavigation.FeedlyViewPager.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 (!mTopEdge.isFinished()) {
            final int height = getHeight();
            final int width = getWidth() - getPaddingLeft() - getPaddingRight();

            mTopEdge.setSize(width, height);

            needsInvalidate |= mTopEdge.draw(canvas);
        }/*from w  ww.  ja  va 2  s. c  o m*/
        if (!mBottomEdge.isFinished()) {
            final int restoreCount = canvas.save();
            final int height = getHeight();
            final int width = getWidth() - getPaddingLeft() - getPaddingRight();
            canvas.rotate(180);
            canvas.translate(-width, -(mLastOffset + 1) * height);

            mBottomEdge.setSize(width, height);
            needsInvalidate |= mBottomEdge.draw(canvas);
            canvas.restoreToCount(restoreCount);
        }
    } else {
        mTopEdge.finish();
        mBottomEdge.finish();
    }

    if (needsInvalidate) {
        // Keep animating
        ViewCompat.postInvalidateOnAnimation(this);
    }
}

From source file:com.zlk.bigdemo.freeza.widget.verticalviewpage.VerticalViewPager.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 (!mTopEdge.isFinished()) {
            final int height = getHeight();
            final int width = getWidth() - getPaddingLeft() - getPaddingRight();

            mTopEdge.setSize(width, height);

            needsInvalidate |= mTopEdge.draw(canvas);
        }//w  w w.  j a va2  s  . c  o  m
        if (!mBottomEdge.isFinished()) {
            // TODO: fix me!
            final int height = getHeight();
            final int width = getWidth() - getPaddingLeft() - getPaddingRight();

            //                canvas.rotate(90);
            //                canvas.rotate(180);
            //                canvas.translate(-getPaddingTop(), -(mLastOffset + 1) * width);
            //                canvas.translate(-(mLastOffset + 1) * height, -getPaddingRight());

            mBottomEdge.setSize(width, height);
            //                mBottomEdge.setHeight(height, width);

            needsInvalidate |= mBottomEdge.draw(canvas);
            //                canvas.restoreToCount(restoreCount);
        }
    } else {
        mTopEdge.finish();
        mBottomEdge.finish();
    }

    if (needsInvalidate) {
        // Keep animating
        ViewCompat.postInvalidateOnAnimation(this);
    }
}