當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。