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


Java MotionEvent.ACTION_POINTER_INDEX_MASK属性代码示例

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


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

示例1: onSecondaryPointerUp

private void onSecondaryPointerUp(MotionEvent ev) {
    final int pointerIndex = (ev.getAction() & MotionEvent.ACTION_POINTER_INDEX_MASK) >>
            MotionEvent.ACTION_POINTER_INDEX_SHIFT;
    final int pointerId = ev.getPointerId(pointerIndex);
    if (pointerId == mActivePointerId) {
        // This was our active pointer going up. Choose a new
        // active pointer and adjust accordingly.
        // TODO: Make this decision more intelligent.
        final int newPointerIndex = pointerIndex == 0 ? 1 : 0;
        mLastMotionX = mDownMotionX = ev.getX(newPointerIndex);
        mLastMotionY = ev.getY(newPointerIndex);
        mLastMotionXRemainder = 0;
        mActivePointerId = ev.getPointerId(newPointerIndex);
        if (mVelocityTracker != null) {
            mVelocityTracker.clear();
        }
    }
}
 
开发者ID:michelelacorte,项目名称:FlickLauncher,代码行数:18,代码来源:PagedView.java

示例2: onSecondaryPointerUp

private void onSecondaryPointerUp(MotionEvent ev) {
    final int pointerIndex = (ev.getAction() & MotionEvent.ACTION_POINTER_INDEX_MASK) >>
    MotionEvent.ACTION_POINTER_INDEX_SHIFT;
    final int pointerId = ev.getPointerId(pointerIndex);
    if (pointerId == mActivePointerId) {
        // This was our active pointer going up. Choose a new
        // active pointer and adjust accordingly.
        // TODO: Make this decision more intelligent.
        final int newPointerIndex = pointerIndex == 0 ? 1 : 0;
        mMotionX = (int) ev.getX(newPointerIndex);
        mMotionY = (int) ev.getY(newPointerIndex);
        mActivePointerId = ev.getPointerId(newPointerIndex);
        if (mVelocityTracker != null) {
            mVelocityTracker.clear();
        }
    }
}
 
开发者ID:Shmilyz,项目名称:Swap,代码行数:17,代码来源:PLA_AbsListView.java

示例3: onTouchEvent

@Override
public boolean onTouchEvent(MotionEvent ev) {
	final int action = ev.getAction();
	switch (action & MotionEvent.ACTION_MASK) {
		case MotionEvent.ACTION_DOWN:
			mActivePointerId = ev.getPointerId(0);
			break;
		case MotionEvent.ACTION_CANCEL:
		case MotionEvent.ACTION_UP:
			mActivePointerId = INVALID_POINTER_ID;
			break;
		case MotionEvent.ACTION_POINTER_UP:
			final int pointerIndex = (ev.getAction() & MotionEvent.ACTION_POINTER_INDEX_MASK) >> MotionEvent.ACTION_POINTER_INDEX_SHIFT;
			final int pointerId = ev.getPointerId(pointerIndex);
			if (pointerId == mActivePointerId) {
				// This was our active pointer going up. Choose a new
				// active pointer and adjust accordingly.
				final int newPointerIndex = pointerIndex == 0 ? 1 : 0;
				mActivePointerId = ev.getPointerId(newPointerIndex);
				mLastTouchX = ev.getX(newPointerIndex);
				mLastTouchY = ev.getY(newPointerIndex);
			}
			break;
	}

	mActivePointerIndex = ev.findPointerIndex(mActivePointerId != INVALID_POINTER_ID ? mActivePointerId : 0);
	return super.onTouchEvent(ev);
}
 
开发者ID:mangestudio,项目名称:GCSApp,代码行数:28,代码来源:VersionedGestureDetector.java

示例4: actionToString

public static String actionToString(int action) {
    switch (action) {
        case MotionEvent.ACTION_DOWN:
            return "ACTION_DOWN";
        case MotionEvent.ACTION_UP:
            return "ACTION_UP";
        case MotionEvent.ACTION_CANCEL:
            return "ACTION_CANCEL";
        case MotionEvent.ACTION_OUTSIDE:
            return "ACTION_OUTSIDE";
        case MotionEvent.ACTION_MOVE:
            return "ACTION_MOVE";
        case MotionEvent.ACTION_HOVER_MOVE:
            return "ACTION_HOVER_MOVE";
        case MotionEvent.ACTION_SCROLL:
            return "ACTION_SCROLL";
        case MotionEvent.ACTION_HOVER_ENTER:
            return "ACTION_HOVER_ENTER";
        case MotionEvent.ACTION_HOVER_EXIT:
            return "ACTION_HOVER_EXIT";
        case MotionEvent.ACTION_BUTTON_PRESS:
            return "ACTION_BUTTON_PRESS";
        case MotionEvent.ACTION_BUTTON_RELEASE:
            return "ACTION_BUTTON_RELEASE";
    }
    int index = (action & MotionEvent.ACTION_POINTER_INDEX_MASK) >> MotionEvent.ACTION_POINTER_INDEX_SHIFT;
    switch (action & MotionEvent.ACTION_MASK) {
        case MotionEvent.ACTION_POINTER_DOWN:
            return "ACTION_POINTER_DOWN(" + index + ")";
        case MotionEvent.ACTION_POINTER_UP:
            return "ACTION_POINTER_UP(" + index + ")";
        default:
            return Integer.toString(action);
    }
}
 
开发者ID:HanyeeWang,项目名称:GeekZone,代码行数:35,代码来源:ViewUtils.java

示例5: onTouchEvent

@Override
public boolean onTouchEvent(MotionEvent ev) {
    final int action = ev.getAction();
    switch (action & MotionEvent.ACTION_MASK) {
        case MotionEvent.ACTION_DOWN:
            mActivePointerId = ev.getPointerId(0);
            break;
        case MotionEvent.ACTION_CANCEL:
        case MotionEvent.ACTION_UP:
            mActivePointerId = INVALID_POINTER_ID;
            break;
        case MotionEvent.ACTION_POINTER_UP:
            final int pointerIndex = (ev.getAction() & MotionEvent.ACTION_POINTER_INDEX_MASK) >> MotionEvent.ACTION_POINTER_INDEX_SHIFT;
            final int pointerId = ev.getPointerId(pointerIndex);
            if (pointerId == mActivePointerId) {
                // This was our active pointer going up. Choose a new
                // active pointer and adjust accordingly.
                final int newPointerIndex = pointerIndex == 0 ? 1 : 0;
                mActivePointerId = ev.getPointerId(newPointerIndex);
                mLastTouchX = ev.getX(newPointerIndex);
                mLastTouchY = ev.getY(newPointerIndex);
            }
            break;
    }

    mActivePointerIndex = ev.findPointerIndex(mActivePointerId != INVALID_POINTER_ID ? mActivePointerId : 0);
    return super.onTouchEvent(ev);
}
 
开发者ID:mangestudio,项目名称:GCSApp,代码行数:28,代码来源:VersionedGestureDetector.java

示例6: onTouch

@Override
public boolean onTouch(View view, MotionEvent event) {
    mScaleGestureDetector.onTouchEvent(view, event);

    if (!isTranslateEnabled) {
        return true;
    }

    int action = event.getAction();

    int x = (int) event.getRawX();
    int y = (int) event.getRawY();

    switch (action & event.getActionMasked()) {
        case MotionEvent.ACTION_DOWN:
            mPrevX = event.getX();
            mPrevY = event.getY();
            mPrevRawX = event.getRawX();
            mPrevRawY = event.getRawY();
            mActivePointerId = event.getPointerId(0);
            deleteView.setVisibility(View.VISIBLE);
            view.bringToFront();
            firePhotoEditorSDKListener(view, true);
            break;
        case MotionEvent.ACTION_MOVE:
            int pointerIndexMove = event.findPointerIndex(mActivePointerId);
            if (pointerIndexMove != -1) {
                float currX = event.getX(pointerIndexMove);
                float currY = event.getY(pointerIndexMove);
                if (!mScaleGestureDetector.isInProgress()) {
                    adjustTranslation(view, currX - mPrevX, currY - mPrevY);
                }
            }
            break;
        case MotionEvent.ACTION_CANCEL:
            mActivePointerId = INVALID_POINTER_ID;
            break;
        case MotionEvent.ACTION_UP:
            mActivePointerId = INVALID_POINTER_ID;
            if (isViewInBounds(deleteView, x, y)) {
                if (onMultiTouchListener != null)
                    onMultiTouchListener.onRemoveViewListener(view);
            } else if (!isViewInBounds(photoEditImageView, x, y)) {
                view.animate().translationY(0).translationY(0);
            }
            deleteView.setVisibility(View.GONE);
            firePhotoEditorSDKListener(view, false);
            float mCurrentCancelX = event.getRawX();
            float mCurrentCancelY = event.getRawY();
            if (mCurrentCancelX == mPrevRawX || mCurrentCancelY == mPrevRawY) {
                if (view instanceof TextView) {
                    if (onMultiTouchListener != null) {
                        onMultiTouchListener.onEditTextClickListener(
                                ((TextView) view).getText().toString(), ((TextView) view).getCurrentTextColor());
                    }
                    if (onPhotoEditorSDKListener != null) {
                        onPhotoEditorSDKListener.onEditTextChangeListener(
                                ((TextView) view).getText().toString(), ((TextView) view).getCurrentTextColor());
                    }
                }
            }
            break;
        case MotionEvent.ACTION_POINTER_UP:
            int pointerIndexPointerUp = (action & MotionEvent.ACTION_POINTER_INDEX_MASK) >> MotionEvent.ACTION_POINTER_INDEX_SHIFT;
            int pointerId = event.getPointerId(pointerIndexPointerUp);
            if (pointerId == mActivePointerId) {
                int newPointerIndex = pointerIndexPointerUp == 0 ? 1 : 0;
                mPrevX = event.getX(newPointerIndex);
                mPrevY = event.getY(newPointerIndex);
                mActivePointerId = event.getPointerId(newPointerIndex);
            }
            break;
    }

    return true;
}
 
开发者ID:eventtus,项目名称:photo-editor-android,代码行数:76,代码来源:MultiTouchListener.java

示例7: onTouchEvent

@Override
public boolean onTouchEvent(MotionEvent ev) {
    final int action = ev.getAction();
    switch (action & MotionEvent.ACTION_MASK) {
    case MotionEvent.ACTION_DOWN:
        mActivePointerId = ev.getPointerId(0);
        break;
    case MotionEvent.ACTION_CANCEL:
    case MotionEvent.ACTION_UP:
        mActivePointerId = INVALID_POINTER_ID;
        break;
    case MotionEvent.ACTION_POINTER_UP:
        final int pointerIndex = (ev.getAction() & MotionEvent.ACTION_POINTER_INDEX_MASK)
                >> MotionEvent.ACTION_POINTER_INDEX_SHIFT;
        final int pointerId = ev.getPointerId(pointerIndex);
        if (pointerId == mActivePointerId) {
            // This was our active pointer going up. Choose a new
            // active pointer and adjust accordingly.
            final int newPointerIndex = pointerIndex == 0 ? 1 : 0;
            mActivePointerId = ev.getPointerId(newPointerIndex);
            mLastTouchX = ev.getX(newPointerIndex);
            mLastTouchY = ev.getY(newPointerIndex);
        }
        break;
    }

    mActivePointerIndex = ev.findPointerIndex(mActivePointerId);
    return super.onTouchEvent(ev);
}
 
开发者ID:sdrausty,项目名称:buildAPKsSamples,代码行数:29,代码来源:VersionedGestureDetector.java

示例8: onTouchEvent

@Override
public boolean onTouchEvent (MotionEvent event) {

    switch (event.getAction() & MotionEvent.ACTION_MASK) {
        case MotionEvent.ACTION_DOWN:
            mDownX = (int)event.getX();
            mDownY = (int)event.getY();
            mActivePointerId = event.getPointerId(0);
            break;
        case MotionEvent.ACTION_MOVE:
            if (mActivePointerId == INVALID_POINTER_ID) {
                break;
            }

            int pointerIndex = event.findPointerIndex(mActivePointerId);

            mLastEventY = (int) event.getY(pointerIndex);
            int deltaY = mLastEventY - mDownY;

            if (mCellIsMobile) {
                mHoverCellCurrentBounds.offsetTo(mHoverCellOriginalBounds.left,
                        mHoverCellOriginalBounds.top + deltaY + mTotalOffset);
                mHoverCell.setBounds(mHoverCellCurrentBounds);
                invalidate();

                handleCellSwitch();

                mIsMobileScrolling = false;
                handleMobileCellScroll();

                return false;
            }
            break;
        case MotionEvent.ACTION_UP:
            touchEventsEnded();
            break;
        case MotionEvent.ACTION_CANCEL:
            touchEventsCancelled();
            break;
        case MotionEvent.ACTION_POINTER_UP:
            /* If a multitouch event took place and the original touch dictating
             * the movement of the hover cell has ended, then the dragging event
             * ends and the hover cell is animated to its corresponding position
             * in the listview. */
            pointerIndex = (event.getAction() & MotionEvent.ACTION_POINTER_INDEX_MASK) >>
                    MotionEvent.ACTION_POINTER_INDEX_SHIFT;
            final int pointerId = event.getPointerId(pointerIndex);
            if (pointerId == mActivePointerId) {
                touchEventsEnded();
            }
            break;
        default:
            break;
    }

    return super.onTouchEvent(event);
}
 
开发者ID:sdrausty,项目名称:buildAPKsSamples,代码行数:57,代码来源:DynamicListView.java

示例9: getPointerIndexHoneyComb

@TargetApi(Build.VERSION_CODES.HONEYCOMB)
private static int getPointerIndexHoneyComb(int action) {
    return (action & MotionEvent.ACTION_POINTER_INDEX_MASK) >> MotionEvent.ACTION_POINTER_INDEX_SHIFT;
}
 
开发者ID:joelan,项目名称:ClouldReader,代码行数:4,代码来源:Compat.java

示例10: getPointerIndex

public static int getPointerIndex(int action) {
    return (action & MotionEvent.ACTION_POINTER_INDEX_MASK) >> MotionEvent.ACTION_POINTER_INDEX_SHIFT;
}
 
开发者ID:WeiXinqiao,项目名称:Recognize-it,代码行数:3,代码来源:Compat.java

示例11: getPointerIndex

static int getPointerIndex(int action) {
    return (action & MotionEvent.ACTION_POINTER_INDEX_MASK) >> MotionEvent.ACTION_POINTER_INDEX_SHIFT;
}
 
开发者ID:Zyj163,项目名称:yyox,代码行数:3,代码来源:Util.java

示例12: getPointerIndexHoneyComb

@TargetApi(VERSION_CODES.HONEYCOMB)
private static int getPointerIndexHoneyComb(int action) {
    return (action & MotionEvent.ACTION_POINTER_INDEX_MASK) >> MotionEvent.ACTION_POINTER_INDEX_SHIFT;
}
 
开发者ID:Loofer,项目名称:Watermark,代码行数:4,代码来源:Compat.java


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