當前位置: 首頁>>代碼示例>>Java>>正文


Java MotionEventCompat.ACTION_POINTER_UP屬性代碼示例

本文整理匯總了Java中android.support.v4.view.MotionEventCompat.ACTION_POINTER_UP屬性的典型用法代碼示例。如果您正苦於以下問題:Java MotionEventCompat.ACTION_POINTER_UP屬性的具體用法?Java MotionEventCompat.ACTION_POINTER_UP怎麽用?Java MotionEventCompat.ACTION_POINTER_UP使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在android.support.v4.view.MotionEventCompat的用法示例。


在下文中一共展示了MotionEventCompat.ACTION_POINTER_UP屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onTouchEvent

@Override
public boolean onTouchEvent(MotionEvent ev) {
    final int action = MotionEventCompat.getActionMasked(ev);
    if (isBackToStart && action == MotionEvent.ACTION_DOWN) isBackToStart = false;
    switch (mType) {
        case BOTTOM:
            if (!isEnabled() || isBackToStart || canChildScrollDown() || isRefreshing) {
                return false;
            }
            break;
        case TOP:
        default:
            if (!isEnabled() || isBackToStart || canChildScrollUp() || isRefreshing) {
                return false;
            }
            break;
    }
    switch (action) {
        case MotionEvent.ACTION_DOWN:
            mActivePointerId = MotionEventCompat.getPointerId(ev, 0);
            isReady = false;
            break;
        case MotionEvent.ACTION_MOVE:
            if (TouchActionMove(ev)) return false;
            break;
        case MotionEventCompat.ACTION_POINTER_DOWN:
            final int index = MotionEventCompat.getActionIndex(ev);
            mActivePointerId = MotionEventCompat.getPointerId(ev, index);
            break;
        case MotionEventCompat.ACTION_POINTER_UP:
            onSecondaryPointerUp(ev);
            break;
        case MotionEvent.ACTION_UP:
        case MotionEvent.ACTION_CANCEL: {
            return TouchActionCancel(ev);
        }
    }
    return true;
}
 
開發者ID:shenhuanet,項目名稱:AndroidOpen,代碼行數:39,代碼來源:SwipeToRefreshLayout.java

示例2: onInterceptTouchEvent

/**
 * 監聽滑動手勢
 * @param e
 * @return
 */
@Override
public boolean onInterceptTouchEvent(MotionEvent e) {
    final int action = MotionEventCompat.getActionMasked(e);
    final int actionIndex = MotionEventCompat.getActionIndex(e);
    switch (action) {
        case MotionEvent.ACTION_DOWN: {
            mActivePointerId = MotionEventCompat.getPointerId(e, 0);
            mLastTouchX = (int) (MotionEventCompat.getX(e, actionIndex) + 0.5f);
            mLastTouchY = (int) (MotionEventCompat.getY(e, actionIndex) + 0.5f);
        }
        break;

        case MotionEvent.ACTION_POINTER_DOWN: {
            mActivePointerId = MotionEventCompat.getPointerId(e, actionIndex);
            mLastTouchX = (int) (MotionEventCompat.getX(e, actionIndex) + 0.5f);
            mLastTouchY = (int) (MotionEventCompat.getY(e, actionIndex) + 0.5f);
        }
        break;

        case MotionEventCompat.ACTION_POINTER_UP: {
            onPointerUp(e);
        }
        break;
    }

    return super.onInterceptTouchEvent(e);
}
 
開發者ID:wp521,項目名稱:MyFire,代碼行數:32,代碼來源:IRecyclerView.java

示例3: onInterceptTouchEvent

/**
 * 在OnTouchEvent事件之前調用
 *
 * @param ev touch事件
 * @return false不攔截,反之攔截
 */
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
    findTarget();
    final int action = MotionEventCompat.getActionMasked(ev);
    if (isBackToStart && action == MotionEvent.ACTION_DOWN)
        isBackToStart = false;
    switch (mType) {
        case BOTTOM:
            if (!isEnabled() || isBackToStart || (!mBothType && canChildScrollDown()) || isRefreshing)
                return false;
            break;
        case TOP:
        default:
            if (!isEnabled() || isBackToStart || (!mBothType && canChildScrollUp()) || isRefreshing)
                return false;
            break;
    }
    switch (action) {
        case MotionEvent.ACTION_DOWN:
            if (InterceptTouchActionDown(ev)) return false;
        case MotionEvent.ACTION_MOVE:
            if (InterceptTouchActionMove(ev)) return false;
            break;
        case MotionEventCompat.ACTION_POINTER_UP:
            onSecondaryPointerUp(ev);
            break;
        case MotionEvent.ACTION_UP:
        case MotionEvent.ACTION_CANCEL:
            isReady = false;
            mActivePointerId = -1;
            break;
    }
    return isReady;
}
 
開發者ID:shenhuanet,項目名稱:AndroidOpen,代碼行數:40,代碼來源:SwipeToRefreshLayout.java

示例4: onInterceptTouchEvent

@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
    ensureTarget();

    final int action = MotionEventCompat.getActionMasked(ev);
    if (mReturningToStart && action == MotionEvent.ACTION_DOWN) {
        mReturningToStart = false;
    }
    if (!isEnabled() || mReturningToStart || canChildScrollUp() || mRefreshing) {
        // Fail fast if we're not in a state where a swipe is possible
        return false;
    }
    switch (action) {
        case MotionEvent.ACTION_DOWN:
            setTargetOffsetTopAndBottom(mOriginalOffsetTop - mCircleView.getTop(), true);
            mActivePointerId = MotionEventCompat.getPointerId(ev, 0);
            mIsBeingDragged = false;
            final float initialDownY = getMotionEventY(ev, mActivePointerId);
            if (initialDownY == -1) {
                return false;
            }
            mInitialDownY = initialDownY;
            break;

        case MotionEvent.ACTION_MOVE:
            if (mActivePointerId == INVALID_POINTER) {
                Log.e(LOG_TAG, "Got ACTION_MOVE event but don't have an active pointer id.");
                return false;
            }

            final float y = getMotionEventY(ev, mActivePointerId);
            if (y == -1) {
                return false;
            }
            final float yDiff = y - mInitialDownY;
            if (yDiff > mTouchSlop && !mIsBeingDragged) {
                mInitialMotionY = mInitialDownY + mTouchSlop;
                mIsBeingDragged = true;
                mProgress.setAlpha(STARTING_PROGRESS_ALPHA);
            }
            break;

        case MotionEventCompat.ACTION_POINTER_UP:
            onSecondaryPointerUp(ev);
            break;

        case MotionEvent.ACTION_UP:
        case MotionEvent.ACTION_CANCEL:
            mIsBeingDragged = false;
            mActivePointerId = INVALID_POINTER;
            break;
    }
    return mIsBeingDragged;
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:54,代碼來源:SwipeRefreshLayout.java

示例5: onInterceptTouchEvent

/**
 * 主要判斷是否應該攔截子View的事件<br>
 * 如果攔截,則交給自己的OnTouchEvent處理<br>
 * 否者,交給子View處理<br>
 */
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
    ensureTarget();

    final int action = MotionEventCompat.getActionMasked(ev);

    if (mReturningToStart && action == MotionEvent.ACTION_DOWN) {
        mReturningToStart = false;
    }
    if (!isEnabled() || mReturningToStart || mRefreshing || !isChildScrollToTop()) {
        // 如果子View可以滑動,不攔截事件,交給子View處理-下拉刷新
        // 或者子View沒有滑動到底部不攔截事件-上拉加載更多
        return false;
    }

    // 下拉刷新判斷
    switch (action) {
        case MotionEvent.ACTION_DOWN:
            setTargetOffsetTopAndBottom(
                    mOriginalOffsetTop - mHeadViewContainer.getTop(), true);// 恢複HeaderView的初始位置
            mActivePointerId = MotionEventCompat.getPointerId(ev, 0);
            mIsBeingDragged = false;
            final float initialMotionY = getMotionEventY(ev, mActivePointerId);
            if (initialMotionY == -1) {
                return false;
            }
            mInitialMotionY = initialMotionY;// 記錄按下的位置

        case MotionEvent.ACTION_MOVE:
            if (mActivePointerId == INVALID_POINTER) {
                return false;
            }

            final float y = getMotionEventY(ev, mActivePointerId);
            if (y == -1) {
                return false;
            }
            float yDiff = y - mInitialMotionY;// 計算下拉距離
            if (yDiff > mTouchSlop && !mIsBeingDragged) {// 判斷是否下拉的距離足夠
                mIsBeingDragged = true;// 正在下拉
            }
            break;

        case MotionEventCompat.ACTION_POINTER_UP:
            onSecondaryPointerUp(ev);
            break;

        case MotionEvent.ACTION_UP:
        case MotionEvent.ACTION_CANCEL:
            mIsBeingDragged = false;
            mActivePointerId = INVALID_POINTER;
            break;
    }

    return mIsBeingDragged;// 如果正在拖動,則攔截子View的事件
}
 
開發者ID:alibaba,項目名稱:LuaViewPlayground,代碼行數:61,代碼來源:SuperSwipeRefreshLayout.java

示例6: onInterceptTouchEvent

@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
    if (!allowDrag)
        return false;
    ensureTarget();

    final int action = MotionEventCompat.getActionMasked(ev);

    if (mReturningToStart && action == MotionEvent.ACTION_DOWN) {
        mReturningToStart = false;
    }
    final boolean isTop = !canChildScrollUp();
    final boolean isBottom = !canChildScrollDown();

    if (!isEnabled() || mReturningToStart || (!isTop && !isBottom) || tRefreshing || bRefreshing) {
        // Fail fast if we're not in a state where a swipe is possible
        return false;
    }

    switch (action) {
        case MotionEvent.ACTION_DOWN:
            if (!bOriginalOffsetCalculated) {
                bCurrentTargetOffsetTop = bOriginalOffsetTop = getMeasuredHeight();
                bOriginalOffsetCalculated = true;
                Log.e(TAG, "onLayout>>set bOriginalOffsetTop=" + bOriginalOffsetTop);
            }
            tIsBeingDragged = false;
            bIsBeingDragged = false;
            if (isTop) {
                setTargetOffsetTopAndBottom(tCircleView, tOriginalOffsetTop - tCircleView.getTop(), true);
            } else if (isBottom) {
                setTargetOffsetTopAndBottom(bCircleView, bOriginalOffsetTop - bCircleView.getTop(), true);
            } else
                return false;
            mActivePointerId = MotionEventCompat.getPointerId(ev, 0);
            final float initialDownY = getMotionEventY(ev, mActivePointerId);
            if (initialDownY == -1) {
                return false;
            }
            mInitialDownY = initialDownY;
            break;

        case MotionEvent.ACTION_MOVE:
            if (mActivePointerId == INVALID_POINTER) {
                android.util.Log.e(LOG_TAG, "Got ACTION_MOVE event but don't have an active pointer id.");
                return false;
            }

            final float y = getMotionEventY(ev, mActivePointerId);
            if (y == -1) {
                return false;
            }
            final float yDiff = y - mInitialDownY;
            if (isTop && yDiff > mTouchSlop && !tIsBeingDragged) {
                mInitialMotionY = mInitialDownY + mTouchSlop;
                tIsBeingDragged = true;
                tProgress.setAlpha(STARTING_PROGRESS_ALPHA);
            } else if (isBottom && yDiff < 0 && Math.abs(yDiff) > mTouchSlop && !bIsBeingDragged) {
                mInitialMotionY = mInitialDownY - mTouchSlop;
                bIsBeingDragged = true;
                bProgress.setAlpha(STARTING_PROGRESS_ALPHA);
            }
            break;

        case MotionEventCompat.ACTION_POINTER_UP:
            onSecondaryPointerUp(ev);
            break;

        case MotionEvent.ACTION_UP:
        case MotionEvent.ACTION_CANCEL:
            tIsBeingDragged = false;
            bIsBeingDragged = false;
            mActivePointerId = INVALID_POINTER;
            break;
    }

    return tIsBeingDragged || bIsBeingDragged;
}
 
開發者ID:LingjuAI,項目名稱:AssistantBySDK,代碼行數:78,代碼來源:LingjuSwipeRefreshLayout.java

示例7: onInterceptTouchEvent

@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
    if (!allowDrag)
        return false;
    ensureTarget();

    final int action = MotionEventCompat.getActionMasked(ev);

    /*if (mReturningToStart && action == MotionEvent.ACTION_DOWN) {
        mReturningToStart = false;
    }*/
    final boolean isTop = !canChildScrollUp();
    final boolean isBottom = !canChildScrollDown();

    if (!isEnabled() || mReturningToStart || (!isTop && !isBottom) || tRefreshing || bRefreshing) {
        // Fail fast if we're not in a state where a swipe is possible
        return false;
    }

    switch (action) {
        case MotionEvent.ACTION_DOWN:
            if (!bOriginalOffsetCalculated) {
                bCurrentTargetOffsetTop = bOriginalOffsetTop = getMeasuredHeight();
                bOriginalOffsetCalculated = true;
                Log.e(TAG, "onLayout>>set bOriginalOffsetTop=" + bOriginalOffsetTop);
            }
            tIsBeingDragged = false;
            bIsBeingDragged = false;
            if (isBottom) {
                setTargetOffsetTopAndBottom(bCircleView, bOriginalOffsetTop - bCircleView.getTop(), true);
            } else
                return false;
            mActivePointerId = MotionEventCompat.getPointerId(ev, 0);
            final float initialDownY = getMotionEventY(ev, mActivePointerId);
            if (initialDownY == -1) {
                return false;
            }
            mInitialDownY = initialDownY;
            break;

        case MotionEvent.ACTION_MOVE:
            if (mActivePointerId == INVALID_POINTER) {
                android.util.Log.e(LOG_TAG, "Got ACTION_MOVE event but don't have an active pointer id.");
                return false;
            }

            final float y = getMotionEventY(ev, mActivePointerId);
            if (y == -1) {
                return false;
            }
            final float yDiff = y - mInitialDownY;
            if (isBottom && yDiff < 0 && Math.abs(yDiff) > mTouchSlop && !bIsBeingDragged) {
                mInitialMotionY = mInitialDownY - mTouchSlop;
                bIsBeingDragged = true;
                bProgress.setAlpha(STARTING_PROGRESS_ALPHA);
            }
            break;

        case MotionEventCompat.ACTION_POINTER_UP:
            onSecondaryPointerUp(ev);
            break;

        case MotionEvent.ACTION_UP:
        case MotionEvent.ACTION_CANCEL:
            tIsBeingDragged = false;
            bIsBeingDragged = false;
            mActivePointerId = INVALID_POINTER;
            break;
    }

    return tIsBeingDragged || bIsBeingDragged;
}
 
開發者ID:LingjuAI,項目名稱:AssistantBySDK,代碼行數:72,代碼來源:LingjuSwipeUpLoadRefreshLayout.java

示例8: onInterceptTouchEvent

@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
    ensureTargetView();

    final int action = MotionEventCompat.getActionMasked(ev);
    int pointerIndex;

    if (!isEnabled() || canChildScrollUp() || mNestedScrollInProgress) {
        Log.d(TAG, "fast end onIntercept: isEnabled = " + isEnabled() + "; canChildScrollUp = "
                + canChildScrollUp() + " ; mNestedScrollInProgress = " + mNestedScrollInProgress);
        return false;
    }
    switch (action) {
        case MotionEvent.ACTION_DOWN:
            mIsDragging = false;
            mActivePointerId = ev.getPointerId(0);
            pointerIndex = ev.findPointerIndex(mActivePointerId);
            if (pointerIndex < 0) {
                return false;
            }
            mInitialDownX = ev.getX(pointerIndex);
            mInitialDownY = ev.getY(pointerIndex);
            break;

        case MotionEvent.ACTION_MOVE:
            pointerIndex = ev.findPointerIndex(mActivePointerId);
            if (pointerIndex < 0) {
                Log.e(TAG, "Got ACTION_MOVE event but have an invalid active pointer id.");
                return false;
            }

            final float x = ev.getX(pointerIndex);
            final float y = ev.getY(pointerIndex);
            startDragging(x, y);
            break;

        case MotionEventCompat.ACTION_POINTER_UP:
            onSecondaryPointerUp(ev);
            break;

        case MotionEvent.ACTION_UP:
        case MotionEvent.ACTION_CANCEL:
            mIsDragging = false;
            mActivePointerId = INVALID_POINTER;
            break;
    }

    return mIsDragging;
}
 
開發者ID:coopese,項目名稱:qmui,代碼行數:49,代碼來源:QMUIPullRefreshLayout.java

示例9: onInterceptTouchEvent

/**
 * 主要判斷是否應該攔截子View的事件<br>
 * 如果攔截,則交給自己的OnTouchEvent處理<br>
 * 否者,交給子View處理<br>
 */
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
    ensureTarget();

    final int action = MotionEventCompat.getActionMasked(ev);

    if (mReturningToStart && action == MotionEvent.ACTION_DOWN) {
        mReturningToStart = false;
    }
    if (!isEnabled() || mReturningToStart || mRefreshing || mLoadMore
            || (!isChildScrollToTop() && !isChildScrollToBottom())) {
        // 如果子View可以滑動,不攔截事件,交給子View處理-下拉刷新
        // 或者子View沒有滑動到底部不攔截事件-上拉加載更多
        return false;
    }

    // 下拉刷新判斷
    switch (action) {
        case MotionEvent.ACTION_DOWN:
            setTargetOffsetTopAndBottom(
                    mOriginalOffsetTop - mHeadViewContainer.getTop(), true);// 恢複HeaderView的初始位置
            mActivePointerId = MotionEventCompat.getPointerId(ev, 0);
            mIsBeingDragged = false;
            final float initialMotionY = getMotionEventY(ev, mActivePointerId);
            if (initialMotionY == -1) {
                return false;
            }
            mInitialMotionY = initialMotionY;// 記錄按下的位置

        case MotionEvent.ACTION_MOVE:
            if (mActivePointerId == INVALID_POINTER) {
                Log.e(LOG_TAG, "Got ACTION_MOVE event but don't have an active pointer id.");
                return false;
            }

            final float y = getMotionEventY(ev, mActivePointerId);
            if (y == -1) {
                return false;
            }
            float yDiff = 0;
            if (isChildScrollToBottom()) {
                yDiff = mInitialMotionY - y;// 計算上拉距離
                if (yDiff > mTouchSlop && !mIsBeingDragged) {// 判斷是否下拉的距離足夠
                    mIsBeingDragged = true;// 正在上拉
                }
            } else {
                yDiff = y - mInitialMotionY;// 計算下拉距離
                if (yDiff > mTouchSlop && !mIsBeingDragged) {// 判斷是否下拉的距離足夠
                    mIsBeingDragged = true;// 正在下拉
                }
            }
            break;

        case MotionEventCompat.ACTION_POINTER_UP:
            onSecondaryPointerUp(ev);
            break;

        case MotionEvent.ACTION_UP:
        case MotionEvent.ACTION_CANCEL:
            mIsBeingDragged = false;
            mActivePointerId = INVALID_POINTER;
            break;
    }

    return mIsBeingDragged;// 如果正在拖動,則攔截子View的事件
}
 
開發者ID:coderwjq,項目名稱:ZhaZhaShop,代碼行數:71,代碼來源:SuperSwipeRefreshLayout.java

示例10: onInterceptTouchEvent

@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {

    if (!isEnabled() || (canChildScrollUp() && !mRefreshing)) {
        return false;
    }

    final int action = MotionEventCompat.getActionMasked(ev);

    switch (action) {
        case MotionEvent.ACTION_DOWN:
            if (!mRefreshing) {
                setTargetOffsetTop(0);
            }
            mActivePointerId = ev.getPointerId(0);
            mIsBeingDragged = false;
            final float initialMotionY = getMotionEventY(ev, mActivePointerId);
            if (initialMotionY == -1) {
                return false;
            }
            mInitialMotionY = initialMotionY;
            mInitialOffsetTop = mCurrentOffsetTop;
            mDispatchTargetTouchDown = false;
            mDragPercent = 0;
            break;
        case MotionEvent.ACTION_MOVE:
            if (mActivePointerId == INVALID_POINTER) {
                return false;
            }
            final float y = getMotionEventY(ev, mActivePointerId);
            if (y == -1) {
                return false;
            }
            final float yDiff = y - mInitialMotionY;
            if (mRefreshing) {
                mIsBeingDragged = !(yDiff < 0 && mCurrentOffsetTop <= 0);
            } else if (yDiff > mTouchSlop && !mIsBeingDragged) {
                mIsBeingDragged = true;
            }
            break;
        case MotionEvent.ACTION_UP:
        case MotionEvent.ACTION_CANCEL:
            mIsBeingDragged = false;
            mActivePointerId = INVALID_POINTER;
            break;
        case MotionEventCompat.ACTION_POINTER_UP:
            onSecondaryPointerUp(ev);
            break;
    }

    return mIsBeingDragged;
}
 
開發者ID:liuwei1993,項目名稱:Android-PullRefresh,代碼行數:52,代碼來源:PullRefreshLayout.java

示例11: onInterceptTouchEvent

@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {

    if (!mEnabled)
        return false;

    final int action = ev.getAction() & MotionEventCompat.ACTION_MASK;

    if (DEBUG)
        if (action == MotionEvent.ACTION_DOWN)
            Log.v(TAG, "Received ACTION_DOWN");

    if (action == MotionEvent.ACTION_CANCEL || action == MotionEvent.ACTION_UP
            || (action != MotionEvent.ACTION_DOWN && mIsUnableToDrag)) {
        endDrag();
        return false;
    }

    switch (action) {
        case MotionEvent.ACTION_MOVE:
            determineDrag(ev);
            break;
        case MotionEvent.ACTION_DOWN:
            int index = MotionEventCompat.getActionIndex(ev);
            mActivePointerId = MotionEventCompat.getPointerId(ev, index);
            if (mActivePointerId == INVALID_POINTER)
                break;
            mLastMotionX = mInitialMotionX = MotionEventCompat.getX(ev, index);
            mLastMotionY = MotionEventCompat.getY(ev, index);
            if (thisTouchAllowed(ev)) {
                mIsBeingDragged = false;
                mIsUnableToDrag = false;
                if (isMenuOpen() && mViewBehind.menuTouchInQuickReturn(mContent, mCurItem, ev.getX() + mScrollX)) {
                    mQuickReturn = true;
                }
            } else {
                mIsUnableToDrag = true;
            }
            break;
        case MotionEventCompat.ACTION_POINTER_UP:
            onSecondaryPointerUp(ev);
            break;
    }

    if (!mIsBeingDragged) {
        if (mVelocityTracker == null) {
            mVelocityTracker = VelocityTracker.obtain();
        }
        mVelocityTracker.addMovement(ev);
    }
    return mIsBeingDragged || mQuickReturn;
}
 
開發者ID:Datatellit,項目名稱:xlight_android_native,代碼行數:52,代碼來源:CustomViewAbove.java

示例12: onInterceptTouchEvent

@Override
public boolean onInterceptTouchEvent(MotionEvent ev)
{

    if (!mEnabled)
    {
        return false;
    }

    final int action = ev.getAction() & MotionEventCompat.ACTION_MASK;

    if (DEBUG)
    {
        if (action == MotionEvent.ACTION_DOWN)
        {
            Log.v(TAG, "Received ACTION_DOWN");
        }
    }

    if (action == MotionEvent.ACTION_CANCEL || action == MotionEvent.ACTION_UP
            || (action != MotionEvent.ACTION_DOWN && mIsUnableToDrag))
    {
        endDrag();
        return false;
    }

    switch (action)
    {
        case MotionEvent.ACTION_MOVE:
            determineDrag(ev);
            break;
        case MotionEvent.ACTION_DOWN:
            int index = MotionEventCompat.getActionIndex(ev);
            mActivePointerId = MotionEventCompat.getPointerId(ev, index);
            if (mActivePointerId == INVALID_POINTER)
            {
                break;
            }
            mLastMotionX = mInitialMotionX = MotionEventCompat.getX(ev, index);
            mLastMotionY = MotionEventCompat.getY(ev, index);
            if (thisTouchAllowed(ev))
            {
                mIsBeingDragged = false;
                mIsUnableToDrag = false;
                if (isMenuOpen() && mViewBehind.menuTouchInQuickReturn(mContent, mCurItem, ev.getX() + mScrollX))
                {
                    mQuickReturn = true;
                }
            }
            else
            {
                mIsUnableToDrag = true;
            }
            break;
        case MotionEventCompat.ACTION_POINTER_UP:
            onSecondaryPointerUp(ev);
            break;
    }

    if (!mIsBeingDragged)
    {
        if (mVelocityTracker == null)
        {
            mVelocityTracker = VelocityTracker.obtain();
        }
        mVelocityTracker.addMovement(ev);
    }
    return mIsBeingDragged || mQuickReturn;
}
 
開發者ID:HueToYou,項目名稱:ChatExchange-old,代碼行數:69,代碼來源:CustomViewAbove.java

示例13: onInterceptTouchEvent

@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {

	if (!mEnabled)
		return false;

	final int action = ev.getAction() & MotionEventCompat.ACTION_MASK;

	if (DEBUG)
		if (action == MotionEvent.ACTION_DOWN)
			Log.v(TAG, "Received ACTION_DOWN");

	if (action == MotionEvent.ACTION_CANCEL || action == MotionEvent.ACTION_UP
			|| (action != MotionEvent.ACTION_DOWN && mIsUnableToDrag)) {
		endDrag();
		return false;
	}

	switch (action) {
	case MotionEvent.ACTION_MOVE:
		determineDrag(ev);
		break;
	case MotionEvent.ACTION_DOWN:
		int index = MotionEventCompat.getActionIndex(ev);
		mActivePointerId = MotionEventCompat.getPointerId(ev, index);
		if (mActivePointerId == INVALID_POINTER)
			break;
		mLastMotionX = mInitialMotionX = MotionEventCompat.getX(ev, index);
		mLastMotionY = MotionEventCompat.getY(ev, index);
		if (thisTouchAllowed(ev)) {
			mIsBeingDragged = false;
			mIsUnableToDrag = false;
			if (isMenuOpen() && mViewBehind.menuTouchInQuickReturn(mContent, mCurItem, ev.getX() + mScrollX)) {
				mQuickReturn = true;
			}
		} else {
			mIsUnableToDrag = true;
		}
		break;
	case MotionEventCompat.ACTION_POINTER_UP:
		onSecondaryPointerUp(ev);
		break;
	}

	if (!mIsBeingDragged) {
		if (mVelocityTracker == null) {
			mVelocityTracker = VelocityTracker.obtain();
		}
		mVelocityTracker.addMovement(ev);
	}
	return mIsBeingDragged || mQuickReturn;
}
 
開發者ID:6ag,項目名稱:LiuAGeAndroid,代碼行數:52,代碼來源:CustomViewAbove.java

示例14: onInterceptTouchEvent

@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
    ensureTarget();

    final int action = MotionEventCompat.getActionMasked(ev);
    int pointerIndex;

    if (mReturningToStart && action == MotionEvent.ACTION_DOWN) {
        mReturningToStart = false;
    }

    if (!isEnabled() || mReturningToStart || canChildScrollUp()
            || mRefreshing || mNestedScrollInProgress) {
        // Fail fast if we're not in a state where a swipe is possible
        return false;
    }

    switch (action) {
        case MotionEvent.ACTION_DOWN:
            setTargetOffsetTopAndBottom(mOriginalOffsetTop - mCircleView.getTop(), true);
            mActivePointerId = ev.getPointerId(0);
            mIsBeingDragged = false;

            pointerIndex = ev.findPointerIndex(mActivePointerId);
            if (pointerIndex < 0) {
                return false;
            }
            mInitialDownY = ev.getY(pointerIndex);
            break;

        case MotionEvent.ACTION_MOVE:
            if (mActivePointerId == INVALID_POINTER) {
                Log.e(LOG_TAG, "Got ACTION_MOVE event but don't have an active pointer id.");
                return false;
            }

            pointerIndex = ev.findPointerIndex(mActivePointerId);
            if (pointerIndex < 0) {
                return false;
            }
            final float y = ev.getY(pointerIndex);
            startDragging(y);
            break;

        case MotionEventCompat.ACTION_POINTER_UP:
            onSecondaryPointerUp(ev);
            break;

        case MotionEvent.ACTION_UP:
        case MotionEvent.ACTION_CANCEL:
            mIsBeingDragged = false;
            mActivePointerId = INVALID_POINTER;
            break;
    }

    return mIsBeingDragged;
}
 
開發者ID:unixzii,項目名稱:android-source-codes,代碼行數:57,代碼來源:SwipeRefreshLayout.java

示例15: onInterceptTouchEvent

@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {

    if (mRefreshView == null) {
        return false;
    }

    Log.d(TAG, "onInterceptTouchEvent: "+ev.toString());
    final int action = MotionEventCompat.getActionMasked(ev);

    if (mReturningToStart && action == MotionEvent.ACTION_DOWN) {
        // Fail fast if we're not in a state where a swipe is possible
        mReturningToStart = false;
    }

    if (!isEnabled() || canChildScrollUp() || mReturningToStart || mRefreshing) {// 不攔截(禁止掉了 || 刷新中 )
        return false;
    }

    switch (ev.getAction()){
        case MotionEvent.ACTION_DOWN:
            mActivePointerId = MotionEventCompat.getPointerId(ev, 0);
            mIsBeingDragged = false;
            final float initialDownY = getMotionEventY(ev, mActivePointerId);
            if (initialDownY == -1) {//如果沒有有效點擊,就往下傳遞
                return false;
            }
            mInitialDownY = initialDownY;
            mIsInterceptedMoveEvent = false;
            break;

        case MotionEvent.ACTION_MOVE:
            if (mActivePointerId == INVALID_POINTER) {
                Log.e(TAG, "Got ACTION_MOVE event but don't have an active pointer id.");
                return false;
            }

            final float y = getMotionEventY(ev, mActivePointerId);
            if (y == -1) {
                return false;
            }
            mIsInterceptedMoveEvent = true;
            determineUserWhetherBeingDragged(y);
            break;

        case MotionEventCompat.ACTION_POINTER_UP:
            onSecondaryPointerUp(ev);
            break;

        case MotionEvent.ACTION_UP:
        case MotionEvent.ACTION_CANCEL:
            mIsBeingDragged = false;
            mActivePointerId = INVALID_POINTER;
            break;
    }

    return mIsBeingDragged;
}
 
開發者ID:Bvin,項目名稱:gesture-refresh-layout,代碼行數:58,代碼來源:GestureRefreshLayout.java


注:本文中的android.support.v4.view.MotionEventCompat.ACTION_POINTER_UP屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。