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


Java MotionEventCompat.ACTION_MASK属性代码示例

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


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

示例1: onTouchEvent

@Override
public boolean onTouchEvent(MotionEvent event) {
    if (mVirtualCount == 0 || !isEnabled()) {
        return super.onTouchEvent(event);
    }
    if (event.getAction() == MotionEvent.ACTION_DOWN && event.getEdgeFlags() != 0) {
        return false;
    }
    if (mVelocityTracker == null) {
        mVelocityTracker = VelocityTracker.obtain();
    }
    mVelocityTracker.addMovement(event);
    final int action = event.getAction() & MotionEventCompat.ACTION_MASK;
    if (action == MotionEvent.ACTION_MOVE) {
        handleTouchActionMove(event);
    } else {
        if (action == MotionEvent.ACTION_DOWN) {
            handleTouchActionDown(event);
        }
        if (action == MotionEvent.ACTION_CANCEL || action == MotionEvent.ACTION_UP) {
            handleTouchActionUp(event);
        }
    }
    return true;
}
 
开发者ID:rexyren,项目名称:PageScrollView,代码行数:25,代码来源:PageScrollView.java

示例2: onInterceptTouchEvent

@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
    if (mVirtualCount == 0 || !isEnabled()) {
        mIsBeingDragged = false;
    } else {
        final int action = ev.getAction() & MotionEventCompat.ACTION_MASK;
        if (action == MotionEvent.ACTION_MOVE) {
            handleTouchActionMove(ev);
        } else {
            if (action == MotionEvent.ACTION_DOWN) {
                handleTouchActionDown(ev);
            }
            if (action == MotionEvent.ACTION_CANCEL || action == MotionEvent.ACTION_UP) {
                handleTouchActionUp(ev);
            }
        }
    }
    return mIsBeingDragged;
}
 
开发者ID:rexyren,项目名称:PageScrollView,代码行数:19,代码来源:PageScrollView.java

示例3: onInterceptTouchEvent

@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
    if (!isEnabled()) {
        return false;
    }
    switch (MotionEventCompat.getActionMasked(ev) & MotionEventCompat.ACTION_MASK) {
        case MotionEvent.ACTION_CANCEL:
        case MotionEvent.ACTION_UP:
            viewDragHelper.cancel();
            return false;
        case MotionEvent.ACTION_DOWN:
            int index = MotionEventCompat.getActionIndex(ev);
            activePointerId = MotionEventCompat.getPointerId(ev, index);
            if (activePointerId == INVALID_VIEW_POINTER) {
                return false;
            }
            break;
        default:
            break;
    }
    boolean interceptTap = viewDragHelper.isViewUnder(dragView, (int) ev.getX(), (int) ev.getY());
    return viewDragHelper.shouldInterceptTouchEvent(ev) || interceptTap;
}
 
开发者ID:mugku,项目名称:slidingplayersampleapp,代码行数:23,代码来源:SlidingView.java

示例4: onTouchEvent

/**
 * Override method to dispatch touch event to the dragged view.
 *
 * @param ev captured.
 * @return true if the touch event is realized over the drag or second view.
 */
@Override
public boolean onTouchEvent(MotionEvent ev) {
    int actionMasked = MotionEventCompat.getActionMasked(ev);
    if ((actionMasked & MotionEventCompat.ACTION_MASK) == MotionEvent.ACTION_DOWN) {
        activePointerId = MotionEventCompat.getPointerId(ev, actionMasked);
    }
    if (activePointerId == INVALID_VIEW_POINTER) {
        return false;
    }
    viewDragHelper.processTouchEvent(ev);
    if (isClosed()) {
        return false;
    }
    boolean isDragViewHit = isViewHit(dragView, (int) ev.getX(), (int) ev.getY());
    boolean isSecondViewHit = isViewHit(secondView, (int) ev.getX(), (int) ev.getY());
    analyzeTouchToMaximizeIfNeeded(ev, isDragViewHit);
    if (isMaximized()) {
        dragView.dispatchTouchEvent(ev);
    } else {
        dragView.dispatchTouchEvent(cloneMotionEventWithAction(ev, MotionEvent.ACTION_CANCEL));
    }
    return isDragViewHit || isSecondViewHit;
}
 
开发者ID:mugku,项目名称:slidingplayersampleapp,代码行数:29,代码来源:SlidingView.java

示例5: onTouchEvent

@Override
public boolean onTouchEvent(MotionEvent event) {

    switch (event.getAction() & MotionEventCompat.ACTION_MASK) {
        case MotionEvent.ACTION_DOWN:
            mLastMotionX = mInitialMotionX = event.getX();
            mLastMotionY = mInitialMotionY = event.getY();
            break;
        case MotionEvent.ACTION_MOVE:
            float x = event.getX();
            float xDiff = Math.abs(x - mInitialMotionX);
            float y = event.getY();
            float yDiff = Math.abs(y - mInitialMotionY);
            if (yDiff > mTouchSlop && yDiff * 0.5f > xDiff) {//垂直方向
                scrollBy(0, -(int) (y - mLastMotionY + 0.5f));
                int distance = y >= mInitialMotionY ? mScrollDownHeight : mScrollUpHeight;
                if(mScrollListener != null) {
                    float percent = yDiff / distance > 0.99 ? 1 : yDiff / distance;
                    mScrollListener.onScrolling(percent);
                }
            }
            mLastMotionX = event.getX();
            mLastMotionY = event.getY();
            break;
        case MotionEvent.ACTION_UP:
            x = event.getX();
            xDiff = Math.abs(x - mInitialMotionX);
            y = event.getY();
            yDiff = Math.abs(y - mInitialMotionY);
            if (yDiff > mTouchSlop && yDiff * 0.5f > xDiff) {//垂直方向
                FlingRunnable runnable = new FlingRunnable(yDiff, y - mInitialMotionY < 0);
                runnable.start();
            }
            break;
    }
    return super.onTouchEvent(event);
}
 
开发者ID:huyongli,项目名称:SlidingPhotoGallery,代码行数:37,代码来源:GalleryViewPager.java

示例6: onInterceptTouchEvent

/**
 * Override method to intercept only touch events over the drag view and to cancel the drag when
 * the action associated to the MotionEvent is equals to ACTION_CANCEL or ACTION_UP.
 *
 * @param ev captured.
 * @return true if the view is going to process the touch event or false if not.
 */
@Override
public boolean onInterceptTouchEvent(MotionEvent ev)
{
    if (!isEnabled())
    {
        return false;
    }
    switch (MotionEventCompat.getActionMasked(ev) & MotionEventCompat.ACTION_MASK)
    {
        case MotionEvent.ACTION_CANCEL:
        case MotionEvent.ACTION_UP:
            viewDragHelper.cancel();
            return false;
        case MotionEvent.ACTION_DOWN:
            int index = MotionEventCompat.getActionIndex(ev);
            activePointerId = MotionEventCompat.getPointerId(ev, index);
            if (activePointerId == INVALID_POINTER)
            {
                return false;
            }
            break;
        default:
            break;
    }
    boolean interceptTap = viewDragHelper.isViewUnder(dragView, (int) ev.getX(), (int) ev.getY());
    return viewDragHelper.shouldInterceptTouchEvent(ev) || interceptTap;
}
 
开发者ID:jbmlaird,项目名称:DiscogsBrowser,代码行数:34,代码来源:DraggableView.java

示例7: onTouchEvent

/**
 * Override method to dispatch touch event to the dragged view.
 *
 * @param ev captured.
 * @return true if the touch event is realized over the drag or second view.
 */
@Override
public boolean onTouchEvent(MotionEvent ev)
{
    int actionMasked = MotionEventCompat.getActionMasked(ev);
    if ((actionMasked & MotionEventCompat.ACTION_MASK) == MotionEvent.ACTION_DOWN)
    {
        activePointerId = MotionEventCompat.getPointerId(ev, actionMasked);
    }
    if (activePointerId == INVALID_POINTER)
    {
        return false;
    }
    viewDragHelper.processTouchEvent(ev);
    if (isClosed())
    {
        return false;
    }
    boolean isDragViewHit = isViewHit(dragView, (int) ev.getX(), (int) ev.getY());
    boolean isSecondViewHit = isViewHit(secondView, (int) ev.getX(), (int) ev.getY());
    analyzeTouchToMaximizeIfNeeded(ev, isDragViewHit);
    if (isMaximized())
    {
        dragView.dispatchTouchEvent(ev);
    }
    else
    {
        dragView.dispatchTouchEvent(cloneMotionEventWithAction(ev, MotionEvent.ACTION_CANCEL));
    }
    return isDragViewHit || isSecondViewHit;
}
 
开发者ID:jbmlaird,项目名称:DiscogsBrowser,代码行数:36,代码来源:DraggableView.java

示例8: onTouchEvent

public boolean onTouchEvent(MotionEvent ev) {
    if (super.onTouchEvent(ev)) {
        return true;
    }
    if (this.mViewPager == null || this.mViewPager.getAdapter().getCount() == 0) {
        return false;
    }
    int action = ev.getAction() & MotionEventCompat.ACTION_MASK;
    switch (action) {
        case 0:
            this.mActivePointerId = MotionEventCompat.getPointerId(ev, 0);
            this.mLastMotionX = ev.getX();
            break;
        case 1:
        case 3:
            if (!this.mIsDragging) {
                int count = this.mViewPager.getAdapter().getCount();
                int width = getWidth();
                float halfWidth = ((float) width) / 2.0f;
                float sixthWidth = ((float) width) / 6.0f;
                if (this.mCurrentPage > 0 && ev.getX() < halfWidth - sixthWidth) {
                    if (action != 3) {
                        this.mViewPager.setCurrentItem(this.mCurrentPage - 1);
                    }
                    return true;
                } else if (this.mCurrentPage < count - 1 && ev.getX() > halfWidth + sixthWidth) {
                    if (action != 3) {
                        this.mViewPager.setCurrentItem(this.mCurrentPage + 1);
                    }
                    return true;
                }
            }
            this.mIsDragging = false;
            this.mActivePointerId = -1;
            if (this.mViewPager.isFakeDragging()) {
                this.mViewPager.endFakeDrag();
                break;
            }
            break;
        case 2:
            float x = MotionEventCompat.getX(ev, MotionEventCompat.findPointerIndex(ev, this.mActivePointerId));
            float deltaX = x - this.mLastMotionX;
            if (!this.mIsDragging && Math.abs(deltaX) > ((float) this.mTouchSlop)) {
                this.mIsDragging = true;
            }
            if (this.mIsDragging) {
                this.mLastMotionX = x;
                if (this.mViewPager.isFakeDragging() || this.mViewPager.beginFakeDrag()) {
                    this.mViewPager.fakeDragBy(deltaX);
                    break;
                }
            }
            break;
        case 5:
            int index = MotionEventCompat.getActionIndex(ev);
            this.mLastMotionX = MotionEventCompat.getX(ev, index);
            this.mActivePointerId = MotionEventCompat.getPointerId(ev, index);
            break;
        case 6:
            int pointerIndex = MotionEventCompat.getActionIndex(ev);
            if (MotionEventCompat.getPointerId(ev, pointerIndex) == this.mActivePointerId) {
                this.mActivePointerId = MotionEventCompat.getPointerId(ev, pointerIndex == 0 ? 1 : 0);
            }
            this.mLastMotionX = MotionEventCompat.getX(ev, MotionEventCompat.findPointerIndex(ev, this.mActivePointerId));
            break;
    }
    return true;
}
 
开发者ID:bunnyblue,项目名称:NoticeDog,代码行数:68,代码来源:LinePageIndicator.java

示例9: 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

示例10: 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

示例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:6ag,项目名称:LiuAGeAndroid,代码行数:52,代码来源:CustomViewAbove.java


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