当前位置: 首页>>代码示例>>Java>>正文


Java ViewCompat.getOverScrollMode方法代码示例

本文整理汇总了Java中android.support.v4.view.ViewCompat.getOverScrollMode方法的典型用法代码示例。如果您正苦于以下问题:Java ViewCompat.getOverScrollMode方法的具体用法?Java ViewCompat.getOverScrollMode怎么用?Java ViewCompat.getOverScrollMode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.support.v4.view.ViewCompat的用法示例。


在下文中一共展示了ViewCompat.getOverScrollMode方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: computeScroll

import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
public void computeScroll() {
    boolean canOverscroll = true;
    if (this.mScroller.computeScrollOffset()) {
        int oldX = getScrollX();
        int oldY = getScrollY();
        int x = this.mScroller.getCurrX();
        int y = this.mScroller.getCurrY();
        if (oldX != x || oldY != y) {
            int range = getScrollRange();
            int overscrollMode = ViewCompat.getOverScrollMode(this);
            if (overscrollMode != 0 && (overscrollMode != 1 || range <= 0)) {
                canOverscroll = false;
            }
            overScrollByCompat(x - oldX, y - oldY, oldX, oldY, 0, range, 0, 0, false);
            if (canOverscroll) {
                ensureGlows();
                if (y <= 0 && oldY > 0) {
                    this.mEdgeGlowTop.onAbsorb((int) this.mScroller.getCurrVelocity());
                } else if (y >= range && oldY < range) {
                    this.mEdgeGlowBottom.onAbsorb((int) this.mScroller.getCurrVelocity());
                }
            }
        }
    }
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:26,代码来源:NestedScrollView.java

示例2: ensureGlows

import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
private void ensureGlows() {
    if (ViewCompat.getOverScrollMode(this) == 2) {
        this.mEdgeGlowTop = null;
        this.mEdgeGlowBottom = null;
    } else if (this.mEdgeGlowTop == null) {
        Context context = getContext();
        this.mEdgeGlowTop = new EdgeEffectCompat(context);
        this.mEdgeGlowBottom = new EdgeEffectCompat(context);
    }
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:11,代码来源:NestedScrollView.java

示例3: scrollByInternal

import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
/**
 * Does not perform bounds checking. Used by internal methods that have already validated input.
 * <p>
 * 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;
}
 
开发者ID:MLNO,项目名称:airgram,代码行数:61,代码来源:RecyclerView.java

示例4: FullyLinearLayoutManager

import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
public FullyLinearLayoutManager(RecyclerView view) {
    super(view.getContext());
    this.view = view;
    this.overScrollMode = ViewCompat.getOverScrollMode(view);
}
 
开发者ID:lpy19930103,项目名称:MinimalismJotter,代码行数:6,代码来源:FullyLinearLayoutManager.java

示例5: scrollByInternal

import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
boolean scrollByInternal(int x, int y, MotionEvent ev) {
    int unconsumedX = 0;
    int unconsumedY = 0;
    int consumedX = 0;
    int consumedY = 0;
    consumePendingUpdateOperations();
    if (this.mAdapter != null) {
        eatRequestLayout();
        onEnterLayoutOrScroll();
        TraceCompat.beginSection(TRACE_SCROLL_TAG);
        if (x != 0) {
            consumedX = this.mLayout.scrollHorizontallyBy(x, this.mRecycler, this.mState);
            unconsumedX = x - consumedX;
        }
        if (y != 0) {
            consumedY = this.mLayout.scrollVerticallyBy(y, this.mRecycler, this.mState);
            unconsumedY = y - consumedY;
        }
        TraceCompat.endSection();
        repositionShadowingViews();
        onExitLayoutOrScroll();
        resumeRequestLayout(false);
    }
    if (!this.mItemDecorations.isEmpty()) {
        invalidate();
    }
    if (dispatchNestedScroll(consumedX, consumedY, unconsumedX, unconsumedY, this.mScrollOffset)) {
        this.mLastTouchX -= this.mScrollOffset[0];
        this.mLastTouchY -= this.mScrollOffset[1];
        if (ev != null) {
            ev.offsetLocation((float) this.mScrollOffset[0], (float) this.mScrollOffset[1]);
        }
        int[] iArr = this.mNestedOffsets;
        iArr[0] = iArr[0] + this.mScrollOffset[0];
        iArr = this.mNestedOffsets;
        iArr[1] = iArr[1] + this.mScrollOffset[1];
    } else if (ViewCompat.getOverScrollMode(this) != 2) {
        if (ev != null) {
            pullGlows(ev.getX(), (float) unconsumedX, ev.getY(), (float) unconsumedY);
        }
        considerReleasingGlowsOnScroll(x, y);
    }
    if (!(consumedX == 0 && consumedY == 0)) {
        dispatchOnScrolled(consumedX, consumedY);
    }
    if (!awakenScrollBars()) {
        invalidate();
    }
    if (consumedX == 0 && consumedY == 0) {
        return false;
    }
    return true;
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:54,代码来源:RecyclerView.java

示例6: overScrollByCompat

import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
boolean overScrollByCompat(int deltaX, int deltaY, int scrollX, int scrollY, int scrollRangeX, int scrollRangeY, int maxOverScrollX, int maxOverScrollY, boolean isTouchEvent) {
    int overScrollMode = ViewCompat.getOverScrollMode(this);
    boolean canScrollHorizontal = computeHorizontalScrollRange() > computeHorizontalScrollExtent();
    boolean canScrollVertical = computeVerticalScrollRange() > computeVerticalScrollExtent();
    boolean overScrollHorizontal = overScrollMode == 0 || (overScrollMode == 1 && canScrollHorizontal);
    boolean overScrollVertical = overScrollMode == 0 || (overScrollMode == 1 && canScrollVertical);
    int newScrollX = scrollX + deltaX;
    if (!overScrollHorizontal) {
        maxOverScrollX = 0;
    }
    int newScrollY = scrollY + deltaY;
    if (!overScrollVertical) {
        maxOverScrollY = 0;
    }
    int left = -maxOverScrollX;
    int right = maxOverScrollX + scrollRangeX;
    int top = -maxOverScrollY;
    int bottom = maxOverScrollY + scrollRangeY;
    boolean clampedX = false;
    if (newScrollX > right) {
        newScrollX = right;
        clampedX = true;
    } else if (newScrollX < left) {
        newScrollX = left;
        clampedX = true;
    }
    boolean clampedY = false;
    if (newScrollY > bottom) {
        newScrollY = bottom;
        clampedY = true;
    } else if (newScrollY < top) {
        newScrollY = top;
        clampedY = true;
    }
    if (clampedY) {
        this.mScroller.springBack(newScrollX, newScrollY, 0, 0, 0, getScrollRange());
    }
    onOverScrolled(newScrollX, newScrollY, clampedX, clampedY);
    if (clampedX || clampedY) {
        return true;
    }
    return false;
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:44,代码来源:NestedScrollView.java


注:本文中的android.support.v4.view.ViewCompat.getOverScrollMode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。