本文整理匯總了Java中android.view.MotionEvent.ACTION_POINTER_DOWN屬性的典型用法代碼示例。如果您正苦於以下問題:Java MotionEvent.ACTION_POINTER_DOWN屬性的具體用法?Java MotionEvent.ACTION_POINTER_DOWN怎麽用?Java MotionEvent.ACTION_POINTER_DOWN使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類android.view.MotionEvent
的用法示例。
在下文中一共展示了MotionEvent.ACTION_POINTER_DOWN屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onTouch
@Override
public boolean onTouch(View v, MotionEvent event) {
try {
boolean result = mGestureDetector.onTouchEvent(event);
switch (event.getActionMasked()) {
case MotionEvent.ACTION_POINTER_DOWN:
case MotionEvent.ACTION_DOWN:
result |= handleMotionEvent(LowLevelGesture.ACTION_DOWN, event);
break;
case MotionEvent.ACTION_MOVE:
result |= handleMotionEvent(LowLevelGesture.ACTION_MOVE, event);
break;
case MotionEvent.ACTION_UP:
case MotionEvent.ACTION_POINTER_UP:
finishDisallowInterceptTouchEvent(v);
result |= handleMotionEvent(LowLevelGesture.ACTION_UP, event);
result |= handlePanMotionEvent(event);
break;
case MotionEvent.ACTION_CANCEL:
finishDisallowInterceptTouchEvent(v);
result |= handleMotionEvent(LowLevelGesture.ACTION_CANCEL, event);
result |= handlePanMotionEvent(event);
break;
}
return result;
} catch (Exception e) {
WXLogUtils.e("Gesture RunTime Error ", e);
return false;
}
}
示例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
@Override
public boolean onTouchEvent(MotionEvent event) {
if (!isPDFViewReady()) {
return super.onTouchEvent(event);
}
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
case MotionEvent.ACTION_POINTER_DOWN:
pdfView.stopFling();
handler.removeCallbacks(hidePageScrollerRunnable);
if (pdfView.isSwipeVertical()) {
currentPos = event.getRawY() - getY();
} else {
currentPos = event.getRawX() - getX();
}
case MotionEvent.ACTION_MOVE:
if (pdfView.isSwipeVertical()) {
setPosition(event.getRawY() - currentPos + relativeHandlerMiddle);
pdfView.setPositionOffset(relativeHandlerMiddle / (float) getHeight(), false);
} else {
setPosition(event.getRawX() - currentPos + relativeHandlerMiddle);
pdfView.setPositionOffset(relativeHandlerMiddle / (float) getWidth(), false);
}
return true;
case MotionEvent.ACTION_CANCEL:
case MotionEvent.ACTION_UP:
case MotionEvent.ACTION_POINTER_UP:
hideDelayed();
return true;
}
return super.onTouchEvent(event);
}
示例4: 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);
}
示例5: onTouch
@Override
public boolean onTouch(View v, MotionEvent event) {
ImageView view = (ImageView) v;
// Dump touch event to log
dumpEvent(event);
// Handle touch events here...
switch (event.getAction() & MotionEvent.ACTION_MASK) {
case MotionEvent.ACTION_DOWN:
lastPoint.set(event.getX(), event.getY());
mode = DRAG;
break;
case MotionEvent.ACTION_POINTER_DOWN:
oldDist = spacing(event);
mode = ZOOM;
break;
case MotionEvent.ACTION_UP:
case MotionEvent.ACTION_POINTER_UP:
mode = NONE;
break;
case MotionEvent.ACTION_MOVE:
if (mode == DRAG) {
// Do nothing at the outer left side. Probably the user opened the navigation drawer:
if (event.getX() < LEFT_MARGIN)
return false;
float xDiff = event.getX() - lastPoint.x;
float yDiff = event.getY() - lastPoint.y;
float diff;
if (Math.abs(xDiff) > Math.abs(yDiff)) {
diff = xDiff;
if (event.getY() < view.getHeight() / 2)
diff *= -1;
}
else {
diff = yDiff;
if (event.getX() > view.getWidth() / 2)
diff *= -1;
}
float fac = .25f;
int iDiff = Math.round(diff * fac);
mPlanetChangeCallBacks.addAngle(iDiff);
lastPoint.set(event.getX(), event.getY());
} else if (mode == ZOOM) {
float newDist = spacing(event);
float scale = newDist / oldDist;
mPlanetChangeCallBacks.addScaleLog(scale * scale);
oldDist = newDist;
}
break;
}
return true; // indicate event was handled
}
示例6: onTouchEvent
public boolean onTouchEvent(MotionEvent event){
switch (event.getActionMasked()) {
case MotionEvent.ACTION_DOWN:
ptrID1 = event.getPointerId(event.getActionIndex());
break;
case MotionEvent.ACTION_POINTER_DOWN:
ptrID2 = event.getPointerId(event.getActionIndex());
sX = event.getX(event.findPointerIndex(ptrID1));
sY = event.getY(event.findPointerIndex(ptrID1));
fX = event.getX(event.findPointerIndex(ptrID2));
fY = event.getY(event.findPointerIndex(ptrID2));
break;
case MotionEvent.ACTION_MOVE:
if(ptrID1 != INVALID_POINTER_ID && ptrID2 != INVALID_POINTER_ID){
float nfX, nfY, nsX, nsY;
nsX = event.getX(event.findPointerIndex(ptrID1));
nsY = event.getY(event.findPointerIndex(ptrID1));
nfX = event.getX(event.findPointerIndex(ptrID2));
nfY = event.getY(event.findPointerIndex(ptrID2));
mAngle = angleBetweenLines(fX, fY, sX, sY, nfX, nfY, nsX, nsY);
if (mListener != null) {
mListener.OnRotation(this);
}
}
break;
case MotionEvent.ACTION_UP:
ptrID1 = INVALID_POINTER_ID;
break;
case MotionEvent.ACTION_POINTER_UP:
ptrID2 = INVALID_POINTER_ID;
break;
case MotionEvent.ACTION_CANCEL:
ptrID1 = INVALID_POINTER_ID;
ptrID2 = INVALID_POINTER_ID;
break;
}
return true;
}
示例7: 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;
}
示例8: dispatchTouchEvent
/**
* 處理橫向滑動的事件
*/
@Override
public boolean dispatchTouchEvent(MotionEvent ev) {
int action = ev.getActionMasked();
if (action == MotionEvent.ACTION_DOWN) {
isChildHandle = false;
// 記錄手指按下的位置
startY = ev.getY();
startX = ev.getX();
distanceX = 0;
distanceY = 0;
// 獲取按下的那個View
int position = pointToPosition((int) startX, (int) startY);
touchView = getChildAt(position);
if (hasChildOpen()) {
// 如果觸摸的不是打開的那個View, 關閉所有View,並且攔截所有事件
if (touchView != null && touchView instanceof SwipeRecycleViewItemLayout &&
((SwipeRecycleViewItemLayout) touchView).isOpen()) {
isChildHandle = true; // 將事件交給child!
} else {
closeAllSwipeItem();
//return false;
}
}
}
// 禁用多點觸控
if (action == MotionEvent.ACTION_POINTER_DOWN) {
return false;
}
return super.dispatchTouchEvent(ev);
}
示例9: processTouchEvent
private boolean processTouchEvent(MotionEvent event) {
if (!pressed && event.getActionMasked() == MotionEvent.ACTION_DOWN || event.getActionMasked() == MotionEvent.ACTION_POINTER_DOWN) {
if (!takingPhoto) {
pressed = true;
maybeStartDraging = true;
lastY = event.getY();
}
} else if (pressed) {
if (event.getActionMasked() == MotionEvent.ACTION_MOVE) {
} else if (event.getActionMasked() == MotionEvent.ACTION_CANCEL || event.getActionMasked() == MotionEvent.ACTION_UP || event.getActionMasked() == MotionEvent.ACTION_POINTER_UP) {
pressed = false;
if (dragging) {
dragging = false;
if (cameraView != null) {
if (Math.abs(cameraView.getTranslationY()) > cameraView.getMeasuredHeight() / 6.0f) {
closeCamera(true);
} else {
AnimatorSet animatorSet = new AnimatorSet();
animatorSet.playTogether(
ObjectAnimator.ofFloat(cameraView, "translationY", 0.0f),
ObjectAnimator.ofFloat(cameraPanel, "alpha", 1.0f),
ObjectAnimator.ofFloat(flashModeButton[0], "alpha", 1.0f),
ObjectAnimator.ofFloat(flashModeButton[1], "alpha", 1.0f));
animatorSet.setDuration(250);
animatorSet.setInterpolator(interpolator);
animatorSet.start();
cameraPanel.setTag(null);
}
}
} else {
cameraView.getLocationOnScreen(viewPosition);
float viewX = event.getRawX() - viewPosition[0];
float viewY = event.getRawY() - viewPosition[1];
cameraView.focusToPoint((int) viewX, (int) viewY);
}
}
}
return true;
}
示例10: handleTouch
/**
* Handles the touch event.
*
* @param event
* the touch event
*/
public boolean handleTouch(MotionEvent event) {
int action = event.getAction() & MotionEvent.ACTION_MASK; // same as getActionMask
if (action == MotionEvent.ACTION_MOVE) {
if (event.getPointerCount() == 1) { // slide
float newX = event.getX(0);
float newY = event.getY(0);
if (mfOldX >= 0 && mfOldY >= 0) { // valid last position.
moglChart.slide(mfOldX, mfOldY, newX, newY);
}
mfOldX2 = -1;
mfOldY2 = -1;
mfOldX = newX;
mfOldY = newY;
} else if (event.getPointerCount() == 2) { // pinch
if (!(moglChart instanceof OGLExprChart)) {
// note that OGLExprChart is also instance of OGLChart so cannot use
// if (moglChart instanceof OGLChart)...
pinch2Zoom(event); // data chart pinch to zoom
}
}
} else if (action == MotionEvent.ACTION_DOWN) {
mfOldX = event.getX(0);
mfOldY = event.getY(0);
moglChart.click(mfOldX, mfOldY);
} else if (action == MotionEvent.ACTION_POINTER_DOWN) {
if (event.getPointerCount() == 2) {
mfOldX = event.getX(0);
mfOldY = event.getY(0);
mfOldX2 = event.getX(1);
mfOldY2 = event.getY(1);
} else if (event.getPointerCount() > 2) {
// if more than two pointers, exit pinch to zoom mode.
mfOldX = -1;
mfOldY = -1;
mfOldX2 = -1;
mfOldY2 = -1;
}
} else if (action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_POINTER_UP) {
if (event.getPointerCount() == 2 && moglChart instanceof OGLExprChart) {
pinch2Zoom(event);
}
mfOldX = -1;
mfOldY = -1;
mfOldX2 = -1;
mfOldY2 = -1;
}
//TODO: enable or disable click.
return true; //!mRenderer.isClickEnabled();
}
示例11: onPointerEvent
public void onPointerEvent(MotionEvent event) {
switch (event.getActionMasked()) {
case MotionEvent.ACTION_DOWN:
mSwipeFireable = true;
mDebugFireable = true;
mDownPointers = 0;
captureDown(event, 0);
break;
case MotionEvent.ACTION_POINTER_DOWN:
captureDown(event, event.getActionIndex());
if (mDebugFireable) {
mDebugFireable = event.getPointerCount() < 5;
if (!mDebugFireable) {
mCallbacks.onDebug();
}
}
break;
case MotionEvent.ACTION_MOVE:
if (mSwipeFireable) {
final int swipe = detectSwipe(event);
mSwipeFireable = swipe == SWIPE_NONE;
if (swipe == SWIPE_FROM_TOP) {
mCallbacks.onSwipeFromTop();
} else if (swipe == SWIPE_FROM_BOTTOM) {
int y = (int) event.getY();
int navbarH = 200;
int screenH = PhoneWindowManagerHook.screenH;
// XpLog.i("y is " + y + "\n navbarH is " + navbarH + "\n screenH is " + screenH);
if (y > (screenH - navbarH))
mCallbacks.onSwipeFromBottom();
} else if (swipe == SWIPE_FROM_RIGHT) {
mCallbacks.onSwipeFromRight();
}
}
break;
case MotionEvent.ACTION_UP:
case MotionEvent.ACTION_CANCEL:
mSwipeFireable = false;
mDebugFireable = false;
break;
default:
}
}
示例12: onTouch
@Override
public boolean onTouch(View v, MotionEvent event) {
try {
boolean result = mGestureDetector.onTouchEvent(event);
switch (event.getActionMasked()) {
case MotionEvent.ACTION_POINTER_DOWN:
case MotionEvent.ACTION_DOWN:
mIsTouchEventConsumed = false;
/**
* If component has same scroll orientation with it's parent and it's parent not scrollable
* , we should disallow parent in DOWN.
*/
if(hasSameOrientationWithParent() && !isParentScrollable()){
ViewParent p;
if ((p = component.getRealView().getParent()) != null) {
p.requestDisallowInterceptTouchEvent(true);
}
}
result |= handleMotionEvent(LowLevelGesture.ACTION_DOWN, event);
break;
case MotionEvent.ACTION_MOVE:
result |= handleMotionEvent(LowLevelGesture.ACTION_MOVE, event);
break;
case MotionEvent.ACTION_UP:
case MotionEvent.ACTION_POINTER_UP:
finishDisallowInterceptTouchEvent(v);
result |= handleMotionEvent(LowLevelGesture.ACTION_UP, event);
result |= handlePanMotionEvent(event);
break;
case MotionEvent.ACTION_CANCEL:
finishDisallowInterceptTouchEvent(v);
result |= handleMotionEvent(LowLevelGesture.ACTION_CANCEL, event);
result |= handlePanMotionEvent(event);
break;
}
return result;
} catch (Exception e) {
WXLogUtils.e("Gesture RunTime Error ", e);
return false;
}
}
示例13: init
private void init(
int viewTag,
TouchEventType touchEventType,
MotionEvent motionEventToCopy,
long gestureStartTime,
float viewX,
float viewY,
TouchEventCoalescingKeyHelper touchEventCoalescingKeyHelper) {
super.init(viewTag);
SoftAssertions.assertCondition(gestureStartTime != UNSET,
"Gesture start time must be initialized");
short coalescingKey = 0;
int action = (motionEventToCopy.getAction() & MotionEvent.ACTION_MASK);
switch (action) {
case MotionEvent.ACTION_DOWN:
touchEventCoalescingKeyHelper.addCoalescingKey(gestureStartTime);
break;
case MotionEvent.ACTION_UP:
touchEventCoalescingKeyHelper.removeCoalescingKey(gestureStartTime);
break;
case MotionEvent.ACTION_POINTER_DOWN:
case MotionEvent.ACTION_POINTER_UP:
touchEventCoalescingKeyHelper.incrementCoalescingKey(gestureStartTime);
break;
case MotionEvent.ACTION_MOVE:
coalescingKey =
touchEventCoalescingKeyHelper.getCoalescingKey(gestureStartTime);
break;
case MotionEvent.ACTION_CANCEL:
touchEventCoalescingKeyHelper.removeCoalescingKey(gestureStartTime);
break;
default:
throw new RuntimeException("Unhandled MotionEvent action: " + action);
}
mTouchEventType = touchEventType;
mMotionEvent = MotionEvent.obtain(motionEventToCopy);
mCoalescingKey = coalescingKey;
mViewX = viewX;
mViewY = viewY;
}
示例14: onTouchEvent
public boolean onTouchEvent(@NonNull MotionEvent event) {
switch (event.getActionMasked()) {
case MotionEvent.ACTION_DOWN:
sX = event.getX();
sY = event.getY();
mPointerIndex1 = event.findPointerIndex(event.getPointerId(0));
mAngle = 0;
mIsFirstTouch = true;
break;
case MotionEvent.ACTION_POINTER_DOWN:
fX = event.getX();
fY = event.getY();
mPointerIndex2 = event.findPointerIndex(event.getPointerId(event.getActionIndex()));
mAngle = 0;
mIsFirstTouch = true;
break;
case MotionEvent.ACTION_MOVE:
if (mPointerIndex1 != INVALID_POINTER_INDEX && mPointerIndex2 != INVALID_POINTER_INDEX && event.getPointerCount() > mPointerIndex2) {
float nfX, nfY, nsX, nsY;
nsX = event.getX(mPointerIndex1);
nsY = event.getY(mPointerIndex1);
nfX = event.getX(mPointerIndex2);
nfY = event.getY(mPointerIndex2);
if (mIsFirstTouch) {
mAngle = 0;
mIsFirstTouch = false;
} else {
calculateAngleBetweenLines(fX, fY, sX, sY, nfX, nfY, nsX, nsY);
}
if (mListener != null) {
mListener.onRotation(this);
}
fX = nfX;
fY = nfY;
sX = nsX;
sY = nsY;
}
break;
case MotionEvent.ACTION_UP:
mPointerIndex1 = INVALID_POINTER_INDEX;
break;
case MotionEvent.ACTION_POINTER_UP:
mPointerIndex2 = INVALID_POINTER_INDEX;
break;
}
return true;
}
示例15: 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.onShoveBegin(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.onShoveBegin(this);
}
break;
case MotionEvent.ACTION_POINTER_UP:
if (!mSloppyGesture) {
break;
}
break;
}
}