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


Java MotionEvent.ACTION_POINTER_UP属性代码示例

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


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

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

示例2: onTouch

@Override
public boolean onTouch(View v, MotionEvent event) {
  int action = event.getAction();
  if (mOnActivePseudoListner != null) {
    if (action == MotionEvent.ACTION_DOWN || action == MotionEvent.ACTION_POINTER_DOWN) {
      mOnActivePseudoListner.updateActivePseudo(true);
    } else if (action == MotionEvent.ACTION_CANCEL || action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_POINTER_UP) {
      mOnActivePseudoListner.updateActivePseudo(false);
    }
  }
  return mIsConsumeOnTouch;
}
 
开发者ID:erguotou520,项目名称:weex-uikit,代码行数:12,代码来源:TouchActivePseudoListener.java

示例3: onTouchEvent

public boolean onTouchEvent(MotionEvent event) {
    this.mScaleDetector.onTouchEvent(event);
    if (false) {
        onTouchEvent1(event);
        return true;
    }
    PointF curr = new PointF(event.getX(), event.getY());
    if (this.state == State.NONE || this.state == DRAG || this.state == State.FLING || this.state == State.ZOOM) {
        switch (event.getAction()) {
            case MotionEvent.ACTION_DOWN :
                this.last.set(curr);
                setState(DRAG);
                break;
            case MotionEvent.ACTION_UP :
            case MotionEvent.ACTION_POINTER_UP :
                setState(State.NONE);
                break;
            case MotionEvent.ACTION_MOVE :
                if (this.state != State.NONE) {
                    float deltaX = curr.x - this.last.x;
                    float deltaY = curr.y - this.last.y;
                    float fixTransX = getFixDragTrans(deltaX, (float) this.viewWidth, getImageWidth());
                    float fixTransY = getFixDragTrans(deltaY, (float) this.viewHeight, getImageHeight());
                    this.matrix.postTranslate(deltaX, deltaY);
                    this.last.set(curr.x, curr.y);
                    setImageMatrix(this.matrix);
                    break;
                }
                break;
        }
    }
    return true;
}
 
开发者ID:asif-patel,项目名称:ImageMagnifier,代码行数:33,代码来源:TouchImageView.java

示例4: 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:funnyzhaov,项目名称:Tribe,代码行数:28,代码来源:VersionedGestureDetector.java

示例5: onInterceptTouchEvent

@Override
public boolean onInterceptTouchEvent(RecyclerView view, MotionEvent event) {
    int action = event.getActionMasked();
    boolean isScrollIdle = RecyclerListView.this.getScrollState() == RecyclerListView.SCROLL_STATE_IDLE;

    if ((action == MotionEvent.ACTION_DOWN || action == MotionEvent.ACTION_POINTER_DOWN) && currentChildView == null && isScrollIdle) {
        currentChildView = view.findChildViewUnder(event.getX(), event.getY());
        if (currentChildView instanceof ViewGroup) {
            ViewGroup viewGroup = (ViewGroup) currentChildView;
            float x = event.getX() - currentChildView.getLeft();
            float y = event.getY() - currentChildView.getTop();
            final int count = viewGroup.getChildCount();
            for (int i = count - 1; i >= 0; i--) {
                final View child = viewGroup.getChildAt(i);
                if (x >= child.getLeft() && x <= child.getRight() && y >= child.getTop() && y <= child.getBottom()) {
                    if (child.isClickable()) {
                        currentChildView = null;
                        break;
                    }
                }
            }
        }
        currentChildPosition = -1;
        if (currentChildView != null) {
            currentChildPosition = view.getChildPosition(currentChildView);
            MotionEvent childEvent = MotionEvent.obtain(0, 0, event.getActionMasked(), event.getX() - currentChildView.getLeft(), event.getY() - currentChildView.getTop(), 0);
            if (currentChildView.onTouchEvent(childEvent)) {
                interceptedByChild = true;
            }
            childEvent.recycle();
        }
    }

    if (currentChildView != null && !interceptedByChild) {
        try {
            if (event != null) {
                mGestureDetector.onTouchEvent(event);
            }
        } catch (Exception e) {
            FileLog.e("tmessages", e);
        }
    }

    if (action == MotionEvent.ACTION_DOWN || action == MotionEvent.ACTION_POINTER_DOWN) {
        if (!interceptedByChild && currentChildView != null) {
            selectChildRunnable = new Runnable() {
                @Override
                public void run() {
                    if (selectChildRunnable != null && currentChildView != null) {
                        currentChildView.setPressed(true);
                        selectChildRunnable = null;
                    }
                }
            };
            AndroidUtilities.runOnUIThread(selectChildRunnable, ViewConfiguration.getTapTimeout());
        }
    } else if (currentChildView != null && (action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_POINTER_UP || action == MotionEvent.ACTION_CANCEL || !isScrollIdle)) {
        if (selectChildRunnable != null) {
            AndroidUtilities.cancelRunOnUIThread(selectChildRunnable);
            selectChildRunnable = null;
        }
        currentChildView.setPressed(false);
        currentChildView = null;
        interceptedByChild = false;
    }
    return false;
}
 
开发者ID:pooyafaroka,项目名称:PlusGram,代码行数:67,代码来源:RecyclerListView.java

示例6: dispatchTouchEvent

@Override
public boolean dispatchTouchEvent(MotionEvent e) {
    final float height = getHeight();
    final float transY = getTranslationY();
    final float scrollDamp = mAViewParams.mOverScrollDamp * Math.abs(height - Math.abs(transY)) / height;

    switch (e.getActionMasked()) {
        case MotionEvent.ACTION_DOWN: {
            mAViewState.setTouchLastXY(e);
            break;
        }
        case MotionEvent.ACTION_POINTER_DOWN: {
            mAViewState.setTouchDXY(e, scrollDamp);
            break;
        }
        case MotionEvent.ACTION_MOVE: {
            if (mAViewState.getLastAction() == MotionEvent.ACTION_POINTER_UP) {
                mAViewState.setTouchLastXY(e);
            } else {
                mAViewState.setTouchDXY(e, scrollDamp);
            }
            break;
        }
        case MotionEvent.ACTION_POINTER_UP: {
            int indexOfUpPointer = e.getActionIndex();
            if (indexOfUpPointer == 0) {
                mAViewState.setTouchLastXY(e);
            }
            break;
        }
        case MotionEvent.ACTION_UP: {
            mAViewState.resetTouch();
            break;
        }
    }
    return super.dispatchTouchEvent(e);
}
 
开发者ID:anmingyu11,项目名称:OverScrollableRecyclerView-Method1,代码行数:37,代码来源:ARecyclerView.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:
            // Ignore deprecation, ACTION_POINTER_ID_MASK and
            // ACTION_POINTER_ID_SHIFT has same value and are deprecated
            // You can have either deprecation or lint target api warning
            final int pointerIndex = Compat.getPointerIndex(ev.getAction());
            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:snowwolf10285,项目名称:PicShow-zhaipin,代码行数:33,代码来源:EclairGestureDetector.java

示例8: handleInProgressEvent

@Override
protected void handleInProgressEvent(int actionCode, MotionEvent event) {
    switch (actionCode) {
        case MotionEvent.ACTION_POINTER_UP:
            // Gesture ended but
            updateStateByEvent(event);

            if (!mSloppyGesture) {
                mListener.onRotateEnd(this);
            }

            resetState();
            break;

        case MotionEvent.ACTION_CANCEL:
            if (!mSloppyGesture) {
                mListener.onRotateEnd(this);
            }

            resetState();
            break;

        case MotionEvent.ACTION_MOVE:
            updateStateByEvent(event);

            // Only accept the event if our relative pressure is within
            // a certain limit. This can help filter shaky data as a
            // finger is lifted.
            if (mCurrPressure / mPrevPressure > PRESSURE_THRESHOLD) {
                final boolean updatePrevious = mListener.onRotate(this);
                if (updatePrevious) {
                    mPrevEvent.recycle();
                    mPrevEvent = MotionEvent.obtain(event);
                }
            }
            break;
    }
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:38,代码来源:RotateGestureDetector.java

示例9: onInterceptTouchEvent

@Override
public boolean onInterceptTouchEvent(final MotionEvent me) {
    if (mStripVisibilityGroup.isShowingImportantNoticeStrip()) {
        return false;
    }
    // Detecting sliding up finger to show {@link MoreSuggestionsView}.
    if (!mMoreSuggestionsView.isShowingInParent()) {
        mLastX = (int)me.getX();
        mLastY = (int)me.getY();
        return mMoreSuggestionsSlidingDetector.onTouchEvent(me);
    }
    if (mMoreSuggestionsView.isInModalMode()) {
        return false;
    }

    final int action = me.getAction();
    final int index = me.getActionIndex();
    final int x = (int)me.getX(index);
    final int y = (int)me.getY(index);
    if (Math.abs(x - mOriginX) >= mMoreSuggestionsModalTolerance
            || mOriginY - y >= mMoreSuggestionsModalTolerance) {
        // Decided to be in the sliding suggestion mode only when the touch point has been moved
        // upward. Further {@link MotionEvent}s will be delivered to
        // {@link #onTouchEvent(MotionEvent)}.
        mNeedsToTransformTouchEventToHoverEvent =
                AccessibilityUtils.getInstance().isTouchExplorationEnabled();
        mIsDispatchingHoverEventToMoreSuggestions = false;
        return true;
    }

    if (action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_POINTER_UP) {
        // Decided to be in the modal input mode.
        mMoreSuggestionsView.setModalMode();
    }
    return false;
}
 
开发者ID:sergeychilingaryan,项目名称:AOSP-Kayboard-7.1.2,代码行数:36,代码来源:SuggestionStripView.java

示例10: onTouchEvent

@Override
public void onTouchEvent(MotionEvent ev) {
    final int action = ev.getAction();
    // Determine focal point
    final int count = ev.getPointerCount();
    switch (action & MotionEvent.ACTION_MASK) {
        case MotionEvent.ACTION_DOWN:
            if (mVelocityTracker != null)
                mVelocityTracker.recycle();
            mVelocityTracker = VelocityTracker.obtain();
            mVelocityTracker.addMovement(ev);
            break;
        case MotionEvent.ACTION_POINTER_UP:
            if (mVelocityTracker != null) {
                mVelocityTracker.addMovement(ev);
                // Check the dot product of current velocities.
                // If the pointer that left was opposing another velocity vector, clear.
                mVelocityTracker.computeCurrentVelocity(1000, mMaximumFlingVelocity);
                final int upIndex = ev.getActionIndex();
                final int id1 = ev.getPointerId(upIndex);
                final float x1 = mVelocityTracker.getXVelocity(id1);
                final float y1 = mVelocityTracker.getYVelocity(id1);
                for (int i = 0; i < count; i++) {
                    if (i == upIndex) continue;

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

                    final float dot = x + y;
                    if (dot < 0) {
                        mVelocityTracker.clear();
                        break;
                    }
                }
            }
            break;
        case MotionEvent.ACTION_UP:
            if (mVelocityTracker != null) {
                mVelocityTracker.addMovement(ev);
                final int pointerId = ev.getPointerId(0);
                mVelocityTracker.computeCurrentVelocity(1000, mMaximumFlingVelocity);
                float vy = mVelocityTracker.getYVelocity(pointerId);
                float vx = mVelocityTracker.getXVelocity(pointerId);
                if (Math.abs(vx) >= mMinimumFlingVelocity
                        || Math.abs(vy) >= mMinimumFlingVelocity) {
                    mGestureListener.onFling(vx, vy);
                }
                mVelocityTracker.recycle();
                mVelocityTracker = null;
            }
            break;
        case MotionEvent.ACTION_CANCEL:
            if (mVelocityTracker != null) {
                mVelocityTracker.recycle();
                mVelocityTracker = null;
            }
            break;
        default:
            if (mVelocityTracker != null)
                mVelocityTracker.addMovement(ev);
            break;
    }
}
 
开发者ID:dkzwm,项目名称:SmoothRefreshLayout,代码行数:64,代码来源:GestureDetector.java

示例11: handleStartProgressEvent

@Override
protected void handleStartProgressEvent(int actionCode, MotionEvent event) {
    switch (actionCode) {
        case MotionEvent.ACTION_POINTER_DOWN:
            // At least the second finger is on screen now

            resetState(); // In case we missed an UP/CANCEL event
            mPrevEvent = MotionEvent.obtain(event);
            mTimeDelta = 0;

            updateStateByEvent(event);

            // See if we have a sloppy gesture
            mSloppyGesture = isSloppyGesture(event);
            if (!mSloppyGesture) {
                // No, start gesture now
                mGestureInProgress = mListener.onRotateBegin(this);
            }
            break;

        case MotionEvent.ACTION_MOVE:
            if (!mSloppyGesture) {
                break;
            }

            // See if we still have a sloppy gesture
            mSloppyGesture = isSloppyGesture(event);
            if (!mSloppyGesture) {
                // No, start normal gesture now
                mGestureInProgress = mListener.onRotateBegin(this);
            }

            break;

        case MotionEvent.ACTION_POINTER_UP:
            if (!mSloppyGesture) {
                break;
            }

            break;
    }
}
 
开发者ID:CableIM,项目名称:Cable-Android,代码行数:42,代码来源:RotateGestureDetector.java

示例12: onTouch

@Override
public boolean onTouch(View v, MotionEvent event) {
    mScaleDetector.onTouchEvent(event);
    mGestureDetector.onTouchEvent(event);
    PointF curr = new PointF(event.getX(), event.getY());

    if (state == State.NONE || state == State.DRAG || state == State.FLING) {
        switch (event.getAction()) {
            case MotionEvent.ACTION_DOWN:
                last.set(curr);
                if (fling != null)
                    fling.cancelFling();
                setState(State.DRAG);
                break;

            case MotionEvent.ACTION_MOVE:
                if (state == State.DRAG) {
                    float deltaX = curr.x - last.x;
                    float deltaY = curr.y - last.y;
                    float fixTransX = getFixDragTrans(deltaX, viewWidth, getImageWidth());
                    float fixTransY = getFixDragTrans(deltaY, viewHeight, getImageHeight());
                    matrix.postTranslate(fixTransX, fixTransY);
                    fixTrans();
                    last.set(curr.x, curr.y);
                }
                break;

            case MotionEvent.ACTION_UP:
            case MotionEvent.ACTION_POINTER_UP:
                setState(State.NONE);
                break;
        }
    }

    setImageMatrix(matrix);

    //
    // User-defined OnTouchListener
    //
    if (userTouchListener != null) {
        userTouchListener.onTouch(v, event);
    }

    //
    // OnTouchImageViewListener is set: TouchImageView dragged by user.
    //
    if (touchImageViewListener != null) {
        touchImageViewListener.onMove();
    }

    //
    // indicate event was handled
    //
    return true;
}
 
开发者ID:fengdongfei,项目名称:CXJPadProject,代码行数:55,代码来源:TouchImageView.java

示例13: onTouchEvent

@Override
public boolean onTouchEvent(MotionEvent event) {
	// ignore all input while animating
	if (last > 0) {
		return true;
	}

	switch (event.getActionMasked()) {
		case MotionEvent.ACTION_DOWN:
			initSwipe(event, -1);
			break;
		case MotionEvent.ACTION_POINTER_UP:
			if (swiping) {
				initSwipe(event, event.getActionIndex());
				return true;
			}
			break;
		case MotionEvent.ACTION_POINTER_DOWN:
			if (swiping) {
				return true;
			}
			break;
		case MotionEvent.ACTION_MOVE:
			int pointerCount = event.getPointerCount();
			if (swiping) {
				swipe(event);
				return true;
			} else if (initialX > -1 &&
					pointerCount == 1 &&
					inBounds() &&
					Math.abs(getSwipeDistance(event)) > swipeThreshold) {
				startSwipe();
				return true;
			} else if (pointerCount == 1 && inBounds()) {
				// keep ScalingImageView from invoking transform()
				// for an irrelevant event; a single pointer can't
				// scale nor move the image when in bounds
				return true;
			}
			break;
		case MotionEvent.ACTION_CANCEL:
		case MotionEvent.ACTION_UP:
			if (swiping) {
				completeSwipe(event);
				return true;
			}
			break;
	}

	// forward all other events to ScalingImageView
	return super.onTouchEvent(event);
}
 
开发者ID:markusfisch,项目名称:SwipeImageView,代码行数:52,代码来源:SwipeImageView.java

示例14: onTouchEvent

@Override
public void onTouchEvent(RecyclerView recyclerView, MotionEvent event) {
    mGestureDetector.onTouchEvent(event);
    if (DEBUG) {
        Log.d(TAG,
                "on touch: x:" + mInitialTouchX + ",y:" + mInitialTouchY + ", :" + event);
    }
    if (mVelocityTracker != null) {
        mVelocityTracker.addMovement(event);
    }
    if (mActivePointerId == ACTIVE_POINTER_ID_NONE) {
        return;
    }
    final int action = MotionEventCompat.getActionMasked(event);
    final int activePointerIndex = MotionEventCompat
            .findPointerIndex(event, mActivePointerId);
    if (activePointerIndex >= 0) {
        checkSelectForSwipe(action, event, activePointerIndex);
    }
    ViewHolder viewHolder = mSelected;
    if (viewHolder == null) {
        return;
    }
    switch (action) {
        case MotionEvent.ACTION_MOVE: {
            // Find the index of the active pointer and fetch its position
            if (activePointerIndex >= 0) {
                updateDxDy(event, mSelectedFlags, activePointerIndex);
                moveIfNecessary(viewHolder);
                mRecyclerView.removeCallbacks(mScrollRunnable);
                mScrollRunnable.run();
                mRecyclerView.invalidate();
            }
            break;
        }
        case MotionEvent.ACTION_CANCEL:
            if (mVelocityTracker != null) {
                mVelocityTracker.clear();
            }
            // fall through
        case MotionEvent.ACTION_UP:
            select(null, ACTION_STATE_IDLE);
            mActivePointerId = ACTIVE_POINTER_ID_NONE;
            break;
        case MotionEvent.ACTION_POINTER_UP: {
            final int pointerIndex = MotionEventCompat.getActionIndex(event);
            final int pointerId = MotionEventCompat.getPointerId(event, 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 = MotionEventCompat.getPointerId(event, newPointerIndex);
                updateDxDy(event, mSelectedFlags, pointerIndex);
            }
            break;
        }
    }
}
 
开发者ID:MLNO,项目名称:airgram,代码行数:58,代码来源:ItemTouchHelper.java

示例15: dispatchTouchEvent

@Override
public boolean dispatchTouchEvent(MotionEvent ev) {
    switch (ev.getAction()&MotionEvent.ACTION_MASK){
        case  MotionEvent.ACTION_DOWN:
            return pathView.onTouchEvent(ev);
        case MotionEvent.ACTION_POINTER_DOWN:
            isTranslate=true;
            mOldDistance = TouchEventUtil.spacingOfTwoFinger(ev);
            mOldPointer = TouchEventUtil.middleOfTwoFinger(ev);
            Log.i("action test","scale view action_pointer_down");
            break;
        case  MotionEvent.ACTION_MOVE:
            if(!isTranslate)return  pathView.onTouchEvent(ev);
            if(ev.getPointerCount()==2){
                float newDistance = TouchEventUtil.spacingOfTwoFinger(ev);
                float scaleFactor = newDistance / mOldDistance;
                scaleFactor = checkingScale(pathView.getScaleX(), scaleFactor);
                pathView.setScaleX(pathView.getScaleX() * scaleFactor);
                pathView.setScaleY(pathView.getScaleY() * scaleFactor);
                mOldDistance = newDistance;

                PointF newPointer = TouchEventUtil.middleOfTwoFinger(ev);
                pathView.setX(pathView.getX() + newPointer.x - mOldPointer.x);
                pathView.setY(pathView.getY() + newPointer.y - mOldPointer.y);
                mOldPointer = newPointer;
                checkingBorder();
                Log.i("action test","scale view action_move");

            }
        case MotionEvent.ACTION_POINTER_UP:
            break;
        case MotionEvent.ACTION_UP:
            if (!isTranslate) return pathView.onTouchEvent(ev);
            pathView.getMatrix().getValues(mMatrixValus);
            pathView.setScaleAndOffset(pathView.getScaleX(), mMatrixValus[2], mMatrixValus[5]);
            isTranslate = false;
            Log.i("action test","scale view action_up");
            break;
    }

    return true;

}
 
开发者ID:ShaunSheep,项目名称:ScaleSketchPadDemo,代码行数:43,代码来源:ScaleSketchView.java


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