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


Java VelocityTracker.getYVelocity方法代码示例

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


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

示例1: velocityTrackerPointerUpCleanUpIfNecessary

import android.view.VelocityTracker; //导入方法依赖的package包/类
public static void velocityTrackerPointerUpCleanUpIfNecessary(MotionEvent ev,
                                                              VelocityTracker tracker) {

    // Check the dot product of current velocities.
    // If the pointer that left was opposing another velocity vector, clear.
    tracker.computeCurrentVelocity(1000, mMaximumFlingVelocity);
    final int upIndex = ev.getActionIndex();
    final int id1 = ev.getPointerId(upIndex);
    final float x1 = tracker.getXVelocity(id1);
    final float y1 = tracker.getYVelocity(id1);
    for (int i = 0, count = ev.getPointerCount(); i < count; i++) {
        if (i == upIndex)
            continue;

        final int id2 = ev.getPointerId(i);
        final float x = x1 * tracker.getXVelocity(id2);
        final float y = y1 * tracker.getYVelocity(id2);

        final float dot = x + y;
        if (dot < 0) {
            tracker.clear();
            break;
        }
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:26,代码来源:Utils.java

示例2: handleTouchActionUp

import android.view.VelocityTracker; //导入方法依赖的package包/类
private void handleTouchActionUp(MotionEvent ev) {
    if (mIsBeingDragged) {
        mIsBeingDragged = false;
        mPointLast.set(ev.getX(), ev.getY());
        int velocityX = 0, velocityY = 0;
        final VelocityTracker velocityTracker = mVelocityTracker;
        if (velocityTracker != null) {
            velocityTracker.computeCurrentVelocity(1000, mMaximumVelocity);
            velocityX = (int) velocityTracker.getXVelocity();
            velocityY = (int) velocityTracker.getYVelocity();
        }
        if (!flingToWhere((int) (mPointLast.x - mPointDown.x), (int) (mPointLast.y - mPointDown.y), -velocityX, -velocityY)) {
            markAsWillIdle();
        }
    }
    if (mVelocityTracker != null) {
        mVelocityTracker.recycle();
        mVelocityTracker = null;
    }
}
 
开发者ID:rexyren,项目名称:PageScrollView,代码行数:21,代码来源:PageScrollView.java

示例3: onTouchRelease

import android.view.VelocityTracker; //导入方法依赖的package包/类
private void onTouchRelease() {
    final StackCardsView.LayoutParams lp = (StackCardsView.LayoutParams) mTouchChild.getLayoutParams();
    if (lp.fastDismissAllowed) {
        final VelocityTracker velocityTracker2 = mVelocityTracker;
        velocityTracker2.computeCurrentVelocity(1000, mMaxVelocity);
        float xv = velocityTracker2.getXVelocity(mActivePointerId);
        float yv = velocityTracker2.getYVelocity(mActivePointerId);
        if (doFastDisappear(xv, yv)) {
            resetTouch();
            return;
        }
    }
    if (isDistanceAllowDismiss() && isDirectionAllowDismiss()) {
        doSlowDisappear();
    } else {
        animateToInitPos();
    }
    resetTouch();
    mSwipeView.onCoverStatusChanged(isCoverIdle());
}
 
开发者ID:wensefu,项目名称:StackCardsView,代码行数:21,代码来源:SwipeTouchHelper.java

示例4: getCurrentState

import android.view.VelocityTracker; //导入方法依赖的package包/类
@Override
public int getCurrentState(View selectedView, View targetView, int x, int y,
                           VelocityTracker velocityTracker, int selectedPosition,
                           int targetPosition) {
    if(velocityTracker == null) return ClassifyView.MOVE_STATE_NONE;
    int left = x;
    int top = y;
    int right = left + selectedView.getWidth();
    int bottom = top + selectedView.getHeight();
    if((Math.abs(left - targetView.getLeft())+Math.abs(right - targetView.getRight())+
            Math.abs(top - targetView.getTop())+ Math.abs(bottom - targetView.getBottom()))
            <(targetView.getWidth()+targetView.getHeight()
    )/2){
        velocityTracker.computeCurrentVelocity(100);
        float xVelocity = velocityTracker.getXVelocity();
        float yVelocity = velocityTracker.getYVelocity();
        float limit = getVelocity(targetView.getContext());
        if(xVelocity < limit && yVelocity < limit){
            return ClassifyView.MOVE_STATE_MOVE;
        }
    }
    return ClassifyView.MOVE_STATE_NONE;
}
 
开发者ID:AlphaBoom,项目名称:ClassifyView,代码行数:24,代码来源:BaseSubAdapter.java

示例5: computeOverScroll

import android.view.VelocityTracker; //导入方法依赖的package包/类
/**
 */
@Override
float computeOverScroll(int scrollX, int scrollY, boolean clampedX, boolean clampedY, VelocityTracker tracker, int units) {
	if (scrollY != 0 && clampedY) {
		return tracker.getYVelocity() / (units * 0.05f);
	}
	return 0;
}
 
开发者ID:universum-studios,项目名称:android_ui,代码行数:10,代码来源:VerticalPullHelper.java

示例6: getYVelocity

import android.view.VelocityTracker; //导入方法依赖的package包/类
protected float getYVelocity(VelocityTracker velocityTracker) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.FROYO) {
        return velocityTracker.getYVelocity(mActivePointerId);
    }

    return velocityTracker.getYVelocity();
}
 
开发者ID:ultrasonic,项目名称:ultrasonic,代码行数:8,代码来源:DraggableDrawer.java

示例7: checkOnFlingGesture

import android.view.VelocityTracker; //导入方法依赖的package包/类
private boolean checkOnFlingGesture(MotionEvent ev) {
    final VelocityTracker velocityTracker = this.velocityTracker;
    final int pointerId = ev.getPointerId(0);
    velocityTracker.computeCurrentVelocity(1000, MAX_FLING_VELOCITY);
    final float velocityY = velocityTracker.getYVelocity(pointerId);
    final float velocityX = velocityTracker.getXVelocity(pointerId);
    if ((Math.abs(velocityY) >= MIN_FLING_VELOCITY) || (Math.abs(velocityX) >= MIN_FLING_VELOCITY)) {
        return gestureListener.onFling(currentDownEvent, ev, velocityX, velocityY);
    } else {
        return false;
    }
}
 
开发者ID:xyzxqs,项目名称:XphotoView,代码行数:13,代码来源:GooglePhotosGestureDetector.java

示例8: getCurrentState

import android.view.VelocityTracker; //导入方法依赖的package包/类
@Override
public int getCurrentState(View selectedView, View targetView, int x, int y,
                           VelocityTracker velocityTracker, int selectedPosition,
                           int targetPosition) {
    if (velocityTracker == null) return ClassifyView.MOVE_STATE_NONE;
    int left = x;
    int top = y;
    int right = left + selectedView.getWidth();
    int bottom = top + selectedView.getHeight();
    if (canMergeItem(selectedPosition, targetPosition)) {
        if ((Math.abs(left - targetView.getLeft()) + Math.abs(right - targetView.getRight()) +
                Math.abs(top - targetView.getTop()) + Math.abs(bottom - targetView.getBottom()))
                < (targetView.getWidth() + targetView.getHeight()
        ) / 3) {
            return ClassifyView.MOVE_STATE_MERGE;
        }
    }
    if ((Math.abs(left - targetView.getLeft()) + Math.abs(right - targetView.getRight()) +
            Math.abs(top - targetView.getTop()) + Math.abs(bottom - targetView.getBottom()))
            < (targetView.getWidth() + targetView.getHeight()
    ) / 2) {
        velocityTracker.computeCurrentVelocity(100);
        float xVelocity = velocityTracker.getXVelocity();
        float yVelocity = velocityTracker.getYVelocity();
        float limit = getVelocity(targetView.getContext());
        if (xVelocity < limit && yVelocity < limit) {
            return ClassifyView.MOVE_STATE_MOVE;
        }
    }
    return ClassifyView.MOVE_STATE_NONE;
}
 
开发者ID:AlphaBoom,项目名称:ClassifyView,代码行数:32,代码来源:BaseMainAdapter.java

示例9: actionMove

import android.view.VelocityTracker; //导入方法依赖的package包/类
private void actionMove(MotionEvent event) {
    if (scrollable()) {
        final VelocityTracker tracker = mVelocityTracker;
        tracker.computeCurrentVelocity(UNITS_SECOND, maxVelocity);
        mScrollY = mLastScrollY + mDownY - event.getY();
        mVelocity = tracker.getYVelocity();
        measureCurrentLine();
    }
}
 
开发者ID:Zackratos,项目名称:PureMusic,代码行数:10,代码来源:LyricView.java

示例10: onTouchEvent

import android.view.VelocityTracker; //导入方法依赖的package包/类
@Override
public boolean onTouchEvent(MotionEvent event) {
    if(mItemHeight == 0) return true;

    if (mVelocityTracker == null) {
        mVelocityTracker = VelocityTracker.obtain();
    }
    mVelocityTracker.addMovement(event);
    currY = event.getY();

    switch(event.getAction()){
        case MotionEvent.ACTION_DOWN:
            mFlagMayPress = true;
            mHandlerInNewThread.removeMessages(HANDLER_WHAT_REFRESH);
            stopScrolling();
            downY = currY;
            downYGlobal = mCurrDrawGlobalY;
            onScrollStateChange(OnScrollListener.SCROLL_STATE_IDLE);
            getParent().requestDisallowInterceptTouchEvent(true);
            break;
        case MotionEvent.ACTION_MOVE:
            float spanY = downY - currY;

            if(mFlagMayPress && (-mScaledTouchSlop < spanY && spanY < mScaledTouchSlop)){

            }else{
                mFlagMayPress = false;
                mCurrDrawGlobalY = limitY((int)(downYGlobal + spanY));
                calculateFirstItemParameterByGlobalY();
                invalidate();
            }
            onScrollStateChange(OnScrollListener.SCROLL_STATE_TOUCH_SCROLL);
            break;
        case MotionEvent.ACTION_UP:
            if(mFlagMayPress){
                click(event);
            }else {
                final VelocityTracker velocityTracker = mVelocityTracker;
                velocityTracker.computeCurrentVelocity(1000);
                int velocityY = (int) (velocityTracker.getYVelocity() * mFriction);
                if (Math.abs(velocityY) > mMiniVelocityFling) {
                    mScroller.fling(0, mCurrDrawGlobalY, 0, -velocityY,
                            Integer.MIN_VALUE, Integer.MAX_VALUE, limitY(Integer.MIN_VALUE), limitY(Integer.MAX_VALUE));
                    invalidate();
                    onScrollStateChange(OnScrollListener.SCROLL_STATE_FLING);
                }
                mHandlerInNewThread.sendMessageDelayed(getMsg(HANDLER_WHAT_REFRESH), 0);
                releaseVelocityTracker();
            }
            break;
        case MotionEvent.ACTION_CANCEL:
            downYGlobal = mCurrDrawGlobalY;
            stopScrolling();
            mHandlerInNewThread.sendMessageDelayed(getMsg(HANDLER_WHAT_REFRESH), 0);
            break;
    }
    return true ;
}
 
开发者ID:blxble,项目名称:mesh-core-on-android,代码行数:59,代码来源:NumberPickerView.java

示例11: getVelocity

import android.view.VelocityTracker; //导入方法依赖的package包/类
private float getVelocity(VelocityTracker vt) {
    return mSwipeDirection == X ? vt.getXVelocity() :
            vt.getYVelocity();
}
 
开发者ID:enricocid,项目名称:LaunchEnr,代码行数:5,代码来源:SwipeHelper.java

示例12: getPerpendicularVelocity

import android.view.VelocityTracker; //导入方法依赖的package包/类
private float getPerpendicularVelocity(VelocityTracker vt) {
    return mSwipeDirection == X ? vt.getYVelocity() :
            vt.getXVelocity();
}
 
开发者ID:enricocid,项目名称:LaunchEnr,代码行数:5,代码来源:SwipeHelper.java

示例13: onTouchEvent

import android.view.VelocityTracker; //导入方法依赖的package包/类
@SuppressLint("ClickableViewAccessibility")
@Override
public boolean onTouchEvent(MotionEvent event) {
    if (mContentView == null)
        return false;
    int action = event.getAction();
    float y = event.getY();
    mVelocityTracker.addMovement(event);
    switch (action) {
        case MotionEvent.ACTION_DOWN:
            mLastY = downY = y;
            return true;
        case MotionEvent.ACTION_MOVE:
            float dy = y - mLastY;
            if (dy < 0 && mContentView.getTranslationY() == -mContentViewTranslateY) {
                mContentView.onTouchEvent(event);
                return false;
            }
            if (dy > 0 && mContentView.getTranslationY() + dy >= 0) {
                mContentView.setTranslationY(0);
                translationViewPager();
                return super.onTouchEvent(event);
            }
            if (dy < 0 && mContentView.getTranslationY() + dy <= -mContentViewTranslateY) {
                mContentView.setTranslationY(-mContentViewTranslateY);
                translationViewPager();
                return super.onTouchEvent(event);
            }
            mContentView.setTranslationY(mContentView.getTranslationY() + dy);
            translationViewPager();
            mLastY = y;
            break;
        case MotionEvent.ACTION_CANCEL:
        case MotionEvent.ACTION_UP:
            final VelocityTracker velocityTracker = mVelocityTracker;
            velocityTracker.computeCurrentVelocity(1000, mMaximumVelocity);
            float mYVelocity = velocityTracker.getYVelocity();
            if (mContentView.getTranslationY() == 0
                    || mContentView.getTranslationY() == mContentViewTranslateY) {
                break;
            }
            if (Math.abs(mYVelocity) >= 800) {
                if (mYVelocity < 0) {
                    shrink();
                } else {
                    expand();
                }
                return super.onTouchEvent(event);
            }
            if (event.getY() - downY > 0) {
                expand();
            } else {
                shrink();
            }
            break;
    }
    return super.onTouchEvent(event);
}
 
开发者ID:yhyonghao,项目名称:CalendarView_master,代码行数:59,代码来源:CalendarLayout.java

示例14: getYVelocity

import android.view.VelocityTracker; //导入方法依赖的package包/类
public float getYVelocity(VelocityTracker tracker, int pointerId) {
    return tracker.getYVelocity();
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:4,代码来源:VelocityTrackerCompat.java

示例15: onLayoutTouchEvent

import android.view.VelocityTracker; //导入方法依赖的package包/类
public boolean onLayoutTouchEvent(MotionEvent event) {
    if (event.getAction() == 0) {
        this.mHandlingTouchEventFromDown = true;
    }
    if (this.mHandlingTouchEventFromDown) {
        if (this.mIsBeingMove) {
            this.mLastMotionY = event.getY();
        } else {
            onLayoutInterceptTouchEvent(event, this.mHeaderHeight);
            return true;
        }
    }
    if (this.mVelocityTracker == null) {
        this.mVelocityTracker = VelocityTracker.obtain();
    }
    this.mVelocityTracker.addMovement(event);
    int action = event.getAction();
    int count = event.getPointerCount();
    switch (action) {
        case 1:
        case 3:
            if (this.mIsBeingMove) {
                boolean isFling = false;
                float velocityY = 0.0f;
                if (action == 1) {
                    VelocityTracker velocityTracker = this.mVelocityTracker;
                    int pointerId = event.getPointerId(0);
                    velocityTracker.computeCurrentVelocity(1000, (float) this
                            .mMaximumFlingVelocity);
                    velocityY = velocityTracker.getYVelocity(pointerId);
                    if (Math.abs(velocityY) > ((float) this.mMinimumFlingVelocity)) {
                        isFling = true;
                    }
                }
                this.mListener.onMoveEnded(isFling, velocityY);
            }
            resetTouch();
            break;
        case 2:
            float y = event.getY();
            if (this.mIsBeingMove && y != this.mLastMotionY) {
                this.mListener.onMove(y, this.mLastMotionY == -1.0f ? 0.0f : y - this
                        .mLastMotionY);
                this.mLastMotionY = y;
                break;
            }
        case 6:
            this.mVelocityTracker.computeCurrentVelocity(1000, (float) this
                    .mMaximumFlingVelocity);
            int upIndex = event.getActionIndex();
            int id1 = event.getPointerId(upIndex);
            float x1 = this.mVelocityTracker.getXVelocity(id1);
            float y1 = this.mVelocityTracker.getYVelocity(id1);
            for (int i = 0; i < count; i++) {
                if (i != upIndex) {
                    int id2 = event.getPointerId(i);
                    if ((x1 * this.mVelocityTracker.getXVelocity(id2)) + (y1 * this
                            .mVelocityTracker.getYVelocity(id2)) < 0.0f) {
                        this.mVelocityTracker.clear();
                        break;
                    }
                }
            }
            break;
    }
    return true;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:68,代码来源:ViewPagerHeaderHelper.java


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