本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
示例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);
}
示例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);
}
示例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;
}
}
示例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;
}
示例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;
}
}
示例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;
}
}
示例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;
}
示例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);
}
示例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;
}
}
}
示例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;
}