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


Java VelocityTrackerCompat.getYVelocity方法代码示例

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


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

示例1: endFakeDrag

import android.support.v4.view.VelocityTrackerCompat; //导入方法依赖的package包/类
/**
 * End a fake drag of the pager.
 *
 * @see #beginFakeDrag()
 * @see #fakeDragBy(float)
 */
public void endFakeDrag() {
    if (!mFakeDragging) {
        throw new IllegalStateException("No fake drag in progress. Call beginFakeDrag first.");
    }

    final VelocityTracker velocityTracker = mVelocityTracker;
    velocityTracker.computeCurrentVelocity(1000, mMaximumVelocity);
    int initialVelocity = (int) VelocityTrackerCompat.getYVelocity(
            velocityTracker, mActivePointerId);
    mPopulatePending = true;
    final int height = getClientHeight();
    final int scrollY = getScrollY();
    final ItemInfo ii = infoForCurrentScrollPosition();
    final int currentPage = ii.position;
    final float pageOffset = (((float) scrollY / height) - ii.offset) / ii.heightFactor;
    final int totalDelta = (int) (mLastMotionY - mInitialMotionY);
    int nextPage = determineTargetPage(currentPage, pageOffset, initialVelocity,
            totalDelta);
    setCurrentItemInternal(nextPage, true, true, initialVelocity);
    endDrag();

    mFakeDragging = false;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:30,代码来源:VerticalViewPager.java

示例2: endFakeDragVertically

import android.support.v4.view.VelocityTrackerCompat; //导入方法依赖的package包/类
private void endFakeDragVertically() {
    if (mAdapter != null) {
        final VelocityTracker velocityTracker = mVelocityTracker;
        velocityTracker.computeCurrentVelocity(1000, mMaximumVelocity);
        int initialVelocity = (int) VelocityTrackerCompat.getYVelocity(
                velocityTracker, mActivePointerId);
        mPopulatePending = true;
        final int height = getClientHeight();
        final int scrollY = getScrollY();
        final ItemInfo ii = infoForCurrentScrollPosition();
        final int currentPage = ii.position;
        final float pageOffset = (((float) scrollY / height) - ii.offset) / ii.heightFactor;
        final int totalDelta = (int) (mLastMotionY - mInitialMotionY);
        int nextPage = determineTargetPage(currentPage, pageOffset, initialVelocity,
                totalDelta);
        setCurrentItemInternal(nextPage, true, true, initialVelocity);
    }
    endDrag();

    mFakeDragging = false;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:22,代码来源:BaseViewPager.java

示例3: checkHorizontalSwipe

import android.support.v4.view.VelocityTrackerCompat; //导入方法依赖的package包/类
private int checkHorizontalSwipe(ViewHolder viewHolder, int flags) {
    if ((flags & 12) != 0) {
        int dirFlag = this.mDx > 0.0f ? 8 : 4;
        if (this.mVelocityTracker != null && this.mActivePointerId > -1) {
            int velDirFlag;
            this.mVelocityTracker.computeCurrentVelocity(1000, this.mCallback.getSwipeVelocityThreshold(this.mMaxSwipeVelocity));
            float xVelocity = VelocityTrackerCompat.getXVelocity(this.mVelocityTracker, this.mActivePointerId);
            float yVelocity = VelocityTrackerCompat.getYVelocity(this.mVelocityTracker, this.mActivePointerId);
            if (xVelocity > 0.0f) {
                velDirFlag = 8;
            } else {
                velDirFlag = 4;
            }
            float absXVelocity = Math.abs(xVelocity);
            if ((velDirFlag & flags) != 0 && dirFlag == velDirFlag && absXVelocity >= this.mCallback.getSwipeEscapeVelocity(this.mSwipeEscapeVelocity) && absXVelocity > Math.abs(yVelocity)) {
                return velDirFlag;
            }
        }
        float threshold = ((float) this.mRecyclerView.getWidth()) * this.mCallback.getSwipeThreshold(viewHolder);
        if ((flags & dirFlag) != 0 && Math.abs(this.mDx) > threshold) {
            return dirFlag;
        }
    }
    return 0;
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:26,代码来源:ItemTouchHelper.java

示例4: checkVerticalSwipe

import android.support.v4.view.VelocityTrackerCompat; //导入方法依赖的package包/类
private int checkVerticalSwipe(ViewHolder viewHolder, int flags) {
    if ((flags & 3) != 0) {
        int dirFlag = this.mDy > 0.0f ? 2 : 1;
        if (this.mVelocityTracker != null && this.mActivePointerId > -1) {
            int velDirFlag;
            this.mVelocityTracker.computeCurrentVelocity(1000, this.mCallback.getSwipeVelocityThreshold(this.mMaxSwipeVelocity));
            float xVelocity = VelocityTrackerCompat.getXVelocity(this.mVelocityTracker, this.mActivePointerId);
            float yVelocity = VelocityTrackerCompat.getYVelocity(this.mVelocityTracker, this.mActivePointerId);
            if (yVelocity > 0.0f) {
                velDirFlag = 2;
            } else {
                velDirFlag = 1;
            }
            float absYVelocity = Math.abs(yVelocity);
            if ((velDirFlag & flags) != 0 && velDirFlag == dirFlag && absYVelocity >= this.mCallback.getSwipeEscapeVelocity(this.mSwipeEscapeVelocity) && absYVelocity > Math.abs(xVelocity)) {
                return velDirFlag;
            }
        }
        float threshold = ((float) this.mRecyclerView.getHeight()) * this.mCallback.getSwipeThreshold(viewHolder);
        if ((flags & dirFlag) != 0 && Math.abs(this.mDy) > threshold) {
            return dirFlag;
        }
    }
    return 0;
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:26,代码来源:ItemTouchHelper.java

示例5: endFakeDrag

import android.support.v4.view.VelocityTrackerCompat; //导入方法依赖的package包/类
/**
 * End a fake drag of the pager.
 *
 * @see #beginFakeDrag()
 * @see #fakeDragBy(float)
 */
public void endFakeDrag() {
    if (!mFakeDragging) {
        throw new IllegalStateException("No fake drag in progress. Call beginFakeDrag first.");
    }

    if (mAdapter != null) {
        final VelocityTracker velocityTracker = mVelocityTracker;
        velocityTracker.computeCurrentVelocity(1000, mMaximumVelocity);
        int initialVelocity = (int) VelocityTrackerCompat.getYVelocity(
                velocityTracker, mActivePointerId);
        mPopulatePending = true;
        final int height = getClientHeight();
        final int scrollY = getScrollY();
        final ItemInfo ii = infoForCurrentScrollPosition();
        final int currentPage = ii.position;
        final float pageOffset = (((float) scrollY / height) - ii.offset) / ii.heightFactor;
        final int totalDelta = (int) (mLastMotionY - mInitialMotionY);
        int nextPage = determineTargetPage(currentPage, pageOffset, initialVelocity,
                totalDelta);
        setCurrentItemInternal(nextPage, true, true, initialVelocity);
    }
    endDrag();

    mFakeDragging = false;
}
 
开发者ID:joy-inc,项目名称:core-ui,代码行数:32,代码来源:VerticalViewPager.java

示例6: endFakeDrag

import android.support.v4.view.VelocityTrackerCompat; //导入方法依赖的package包/类
/**
 * End a fake drag of the pager.
 *
 * @see #beginFakeDrag()
 * @see #fakeDragBy(float)
 */
public void endFakeDrag() {
  if (!mFakeDragging) {
    throw new IllegalStateException("No fake drag in progress. Call beginFakeDrag first.");
  }

  final VelocityTracker velocityTracker = mVelocityTracker;
  velocityTracker.computeCurrentVelocity(1000, mMaximumVelocity);
  int initialVelocity =
      (int) VelocityTrackerCompat.getYVelocity(velocityTracker, mActivePointerId);
  mPopulatePending = true;
  final int height = getClientHeight();
  final int scrollY = getScrollY();
  final ItemInfo ii = infoForCurrentScrollPosition();
  final int currentPage = ii.position;
  final float pageOffset = (((float) scrollY / height) - ii.offset) / ii.heightFactor;
  final int totalDelta = (int) (mLastMotionY - mInitialMotionY);
  int nextPage = determineTargetPage(currentPage, pageOffset, initialVelocity, totalDelta);
  setCurrentItemInternal(nextPage, true, true, initialVelocity);
  endDrag();

  mFakeDragging = false;
}
 
开发者ID:smuyyh,项目名称:SprintNBA,代码行数:29,代码来源:VerticalViewPager.java

示例7: endFakeDrag

import android.support.v4.view.VelocityTrackerCompat; //导入方法依赖的package包/类
/**
 * End a fake drag of the pager.
 *
 * @see #beginFakeDrag()
 * @see #fakeDragBy(float)
 */
public void endFakeDrag() {
    if (!mFakeDragging) {
        throw new IllegalStateException("No fake drag in progress. Call beginFakeDrag first.");
    }

    final VelocityTracker velocityTracker = mVelocityTracker;
    velocityTracker.computeCurrentVelocity(1000, mMaximumVelocity);
    int initialVelocity = (int)VelocityTrackerCompat.getYVelocity(
            velocityTracker, mActivePointerId);
    mPopulatePending = true;
    final int totalDelta = (int) (mLastMotionX - mInitialMotionX);
    final int scrollX = getScrollX();
    final int widthWithMargin = getWidth() + mPageMargin;
    final int currentPage = scrollX / widthWithMargin;
    final float pageOffset = (float) (scrollX % widthWithMargin) / widthWithMargin;
    int nextPage = determineTargetPage(currentPage, pageOffset, initialVelocity, totalDelta);
    setCurrentItemInternal(nextPage, true, true, initialVelocity);
    endDrag();

    mFakeDragging = false;
}
 
开发者ID:lujianzhao,项目名称:AndroidBase,代码行数:28,代码来源:LazyViewPager.java

示例8: checkHorizontalSwipe

import android.support.v4.view.VelocityTrackerCompat; //导入方法依赖的package包/类
private int checkHorizontalSwipe(ViewHolder viewHolder, int flags) {
    if ((flags & (LEFT | RIGHT)) != 0) {
        final int dirFlag = mDx > 0 ? RIGHT : LEFT;
        if (mVelocityTracker != null && mActivePointerId > -1) {
            mVelocityTracker.computeCurrentVelocity(PIXELS_PER_SECOND,
                    mCallback.getSwipeVelocityThreshold(mMaxSwipeVelocity));
            final float xVelocity = VelocityTrackerCompat
                    .getXVelocity(mVelocityTracker, mActivePointerId);
            final float yVelocity = VelocityTrackerCompat
                    .getYVelocity(mVelocityTracker, mActivePointerId);
            final int velDirFlag = xVelocity > 0f ? RIGHT : LEFT;
            final float absXVelocity = Math.abs(xVelocity);
            if ((velDirFlag & flags) != 0 && dirFlag == velDirFlag &&
                    absXVelocity >= mCallback.getSwipeEscapeVelocity(mSwipeEscapeVelocity) &&
                    absXVelocity > Math.abs(yVelocity)) {
                return velDirFlag;
            }
        }

        final float threshold = mRecyclerView.getWidth() * mCallback
                .getSwipeThreshold(viewHolder);

        if ((flags & dirFlag) != 0 && Math.abs(mDx) > threshold) {
            return dirFlag;
        }
    }
    return 0;
}
 
开发者ID:MLNO,项目名称:airgram,代码行数:29,代码来源:ItemTouchHelper.java

示例9: checkVerticalSwipe

import android.support.v4.view.VelocityTrackerCompat; //导入方法依赖的package包/类
private int checkVerticalSwipe(ViewHolder viewHolder, int flags) {
    if ((flags & (UP | DOWN)) != 0) {
        final int dirFlag = mDy > 0 ? DOWN : UP;
        if (mVelocityTracker != null && mActivePointerId > -1) {
            mVelocityTracker.computeCurrentVelocity(PIXELS_PER_SECOND,
                    mCallback.getSwipeVelocityThreshold(mMaxSwipeVelocity));
            final float xVelocity = VelocityTrackerCompat
                    .getXVelocity(mVelocityTracker, mActivePointerId);
            final float yVelocity = VelocityTrackerCompat
                    .getYVelocity(mVelocityTracker, mActivePointerId);
            final int velDirFlag = yVelocity > 0f ? DOWN : UP;
            final float absYVelocity = Math.abs(yVelocity);
            if ((velDirFlag & flags) != 0 && velDirFlag == dirFlag &&
                    absYVelocity >= mCallback.getSwipeEscapeVelocity(mSwipeEscapeVelocity) &&
                    absYVelocity > Math.abs(xVelocity)) {
                return velDirFlag;
            }
        }

        final float threshold = mRecyclerView.getHeight() * mCallback
                .getSwipeThreshold(viewHolder);
        if ((flags & dirFlag) != 0 && Math.abs(mDy) > threshold) {
            return dirFlag;
        }
    }
    return 0;
}
 
开发者ID:MLNO,项目名称:airgram,代码行数:28,代码来源:ItemTouchHelper.java

示例10: endFakeDrag

import android.support.v4.view.VelocityTrackerCompat; //导入方法依赖的package包/类
/**
 * End a fake drag of the pager.
 *
 * @see #beginFakeDrag()
 * @see #fakeDragBy(float)
 */
public void endFakeDrag() {
    if (!mFakeDragging) {
        throw new IllegalStateException("No fake drag in progress. Call beginFakeDrag first.");
    }

    final VelocityTracker velocityTracker = mVelocityTracker;
    velocityTracker.computeCurrentVelocity(1000, mMaximumVelocity);

    final ItemInfo ii = infoForCurrentScrollPosition();
    final int currentPage = ii.position;

    int initialVelocity, totalDelta;
    float pageOffset;
    if (isOrientationHorizontal()) {
        initialVelocity = (int) VelocityTrackerCompat.getXVelocity(
                velocityTracker, mActivePointerId);
        mPopulatePending = true;
        final int width = getClientWidth();
        final int scrollX = getScrollX();
        pageOffset = (((float) scrollX / width) - ii.offset) / ii.sizeFactor;
        totalDelta = (int) (mLastMotionX - mInitialMotionX);
    } else {
        initialVelocity = (int) VelocityTrackerCompat.getYVelocity(
                velocityTracker, mActivePointerId);
        mPopulatePending = true;
        final int height = getClientHeight();
        final int scrollY = getScrollY();
        pageOffset = (((float) scrollY / height) - ii.offset) / ii.sizeFactor;
        totalDelta = (int) (mLastMotionY - mInitialMotionY);
    }

    int nextPage = determineTargetPage(currentPage, pageOffset, initialVelocity,
            totalDelta);
    setCurrentItemInternal(nextPage, true, true, initialVelocity);
    endDrag();

    mFakeDragging = false;
}
 
开发者ID:m4coding,项目名称:Orientation-ViewPager,代码行数:45,代码来源:OrientationViewPager.java

示例11: getYVelocity

import android.support.v4.view.VelocityTrackerCompat; //导入方法依赖的package包/类
private float getYVelocity() {
    mVelocityTracker.computeCurrentVelocity(1000, mMaximumVelocity);
    return VelocityTrackerCompat.getYVelocity(mVelocityTracker, mActivePointerId);
}
 
开发者ID:Krupen,项目名称:FabulousFilter,代码行数:5,代码来源:ViewPagerBottomSheetBehavior.java

示例12: onTouchEvent

import android.support.v4.view.VelocityTrackerCompat; //导入方法依赖的package包/类
@Override
public boolean onTouchEvent(MotionEvent event) {
    float x = event.getX();
    float y = event.getY();
    float dx = x - mPrevX;
    float dy = y - mPrevY;
    int index = event.getActionIndex();
    int pointerId = event.getPointerId(index);

    switch (event.getAction()) {
        case MotionEvent.ACTION_DOWN:

            if (!mScroller.isFinished()) {
                mScroller.abortAnimation();
            }

            mMode = MODE_RULER_DRAG;
            if (mIsVertical) {
                if (y - mViewportStart >= mHighlightStart &&
                        y - mViewportStart <= mHighlightStart + mHighlightSize) {
                    mMode = MODE_HIGHLIGHT_DRAG;
                }
            } else {
                if (x - mViewportStart >= mHighlightStart &&
                        x - mViewportStart <= mHighlightStart + mHighlightSize) {
                    mMode = MODE_HIGHLIGHT_DRAG;
                }
            }

            if (mVelocityTracker == null) {
                mVelocityTracker = VelocityTracker.obtain();
            } else {
                mVelocityTracker.clear();
            }
            mVelocityTracker.addMovement(event);

            break;
        case MotionEvent.ACTION_MOVE:
            mVelocityTracker.addMovement(event);

            if (mMode == MODE_RULER_DRAG) {
                if (mIsVertical) {
                    setViewportStart(getViewportStart() + dy);
                } else {
                    setViewportStart(getViewportStart() + dx);
                }
            } else if (mMode == MODE_HIGHLIGHT_DRAG) {
                if (mIsVertical) {
                    // Drag highlight by whole pixels for now
                    setHighlightStart(getHighlightStart() + Math.round(dy));
                } else {
                    setHighlightStart(getHighlightStart() + Math.round(dx));
                }
            }

            break;

        case MotionEvent.ACTION_UP:
            if (mMode == MODE_RULER_DRAG) {
                mVelocityTracker.computeCurrentVelocity(1000);
                int vx = (int) (VelocityTrackerCompat.getXVelocity(mVelocityTracker, pointerId));
                int vy = (int) (VelocityTrackerCompat.getYVelocity(mVelocityTracker, pointerId));
                mScroller.fling((int) getViewportStart(), (int) getViewportStart(), vx, vy,
                        -10000, 10000, -10000, 10000);
                this.invalidate();
            }

            break;
    }

    mPrevX = x;
    mPrevY = y;

    return true;
}
 
开发者ID:google,项目名称:spline,代码行数:76,代码来源:RulerView.java

示例13: getYVelocity

import android.support.v4.view.VelocityTrackerCompat; //导入方法依赖的package包/类
private float getYVelocity() {
    this.mVelocityTracker.computeCurrentVelocity(1000, this.mMaximumVelocity);
    return VelocityTrackerCompat.getYVelocity(this.mVelocityTracker, this.mActivePointerId);
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:5,代码来源:BottomSheetBehavior.java


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