當前位置: 首頁>>代碼示例>>Java>>正文


Java MotionEvent.ACTION_MASK屬性代碼示例

本文整理匯總了Java中android.view.MotionEvent.ACTION_MASK屬性的典型用法代碼示例。如果您正苦於以下問題:Java MotionEvent.ACTION_MASK屬性的具體用法?Java MotionEvent.ACTION_MASK怎麽用?Java MotionEvent.ACTION_MASK使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在android.view.MotionEvent的用法示例。


在下文中一共展示了MotionEvent.ACTION_MASK屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onTouchEvent

@Override
public boolean onTouchEvent(MotionEvent event) {
    final int action = event.getAction() & MotionEvent.ACTION_MASK;

    switch (action) {
        case MotionEvent.ACTION_DOWN:
            handleDownAction(event);
            return true;

        case MotionEvent.ACTION_UP:
        case MotionEvent.ACTION_MOVE:
            handleMoveAction(event);
            return true;

        default:
            return false;
    }
}
 
開發者ID:huazhouwang,項目名稱:Synapse,代碼行數:18,代碼來源:DigitView.java

示例2: dumpEvent

private void dumpEvent(MotionEvent event) {
    String names[] = { "DOWN", "UP", "MOVE", "CANCEL", "OUTSIDE",
            "POINTER_DOWN", "POINTER_UP", "7?", "8?", "9?" };
    StringBuilder sb = new StringBuilder();
    int action = event.getAction();
    int actionCode = action & MotionEvent.ACTION_MASK;
    sb.append("event ACTION_").append(names[actionCode]);
    if (actionCode == MotionEvent.ACTION_POINTER_DOWN
            || actionCode == MotionEvent.ACTION_POINTER_UP) {
        sb.append("(pid ").append(
                action >> MotionEvent.ACTION_POINTER_ID_SHIFT);
        sb.append(")");
    }
    sb.append("[");
    for (int i = 0; i < event.getPointerCount(); i++) {
        sb.append("#").append(i);
        sb.append("(pid ").append(event.getPointerId(i));
        sb.append(")=").append((int) event.getX(i));
        sb.append(",").append((int) event.getY(i));
        if (i + 1 < event.getPointerCount())
            sb.append(";");
    }
    sb.append("]");
    //Log.d(TAG, sb.toString());
}
 
開發者ID:SavorGit,項目名稱:Hotspot-master-devp,代碼行數:25,代碼來源:MulitPointTouchListener.java

示例3: onTouchEvent

@Override
public boolean onTouchEvent(MotionEvent ev) {
  if (!mScrollEnabled) {
    return false;
  }

  int action = ev.getAction() & MotionEvent.ACTION_MASK;
  if (action == MotionEvent.ACTION_UP && mDragging) {
    ReactScrollViewHelper.emitScrollEndDragEvent(this);
    mDragging = false;
    // After the touch finishes, we may need to do some scrolling afterwards either as a result
    // of a fling or because we need to page align the content
    handlePostTouchScrolling();
  }
  return super.onTouchEvent(ev);
}
 
開發者ID:qq565999484,項目名稱:RNLearn_Project1,代碼行數:16,代碼來源:ReactHorizontalScrollView.java

示例4: onTouch

@Override
public boolean onTouch(View v, MotionEvent event) {
    switch(event.getAction() & MotionEvent.ACTION_MASK)
    {
        case MotionEvent.ACTION_DOWN:
            startTime = System.currentTimeMillis();
            clickCount++;
            break;
        case MotionEvent.ACTION_UP:
            long time = System.currentTimeMillis() - startTime;
            duration=  duration + time;
            if(clickCount == 2)
            {
                if(duration<= MAX_DURATION)
                {
                    onDoubleTap();
                }
                clickCount = 0;
                duration = 0;
                break;
            }
    }
    return gestureDetector.onTouchEvent(event);
}
 
開發者ID:reyanshmishra,項目名稱:Rey-MusicPlayer,代碼行數:24,代碼來源:onSwipeGestureListener.java

示例5: onTouchEvent

@Override
public boolean onTouchEvent(MotionEvent ev) {
    int action = ev.getAction() & MotionEvent.ACTION_MASK;
    if (action == MotionEvent.ACTION_UP && mDragging) {
        mDragging = false;
        mVelocityHelper.calculateVelocity(ev);
        getReactContext().getNativeModule(UIManagerModule.class).getEventDispatcher()
                .dispatchEvent(ScrollEvent.obtain(
                        getId(),
                        ScrollEventType.END_DRAG,
                        0, /* offsetX = 0, horizontal scrolling only */
                        computeVerticalScrollOffset(),
                        mVelocityHelper.getXVelocity(),
                        mVelocityHelper.getYVelocity(),
                        getWidth(),
                        computeVerticalScrollRange(),
                        getWidth(),
                        getHeight()));
    }
    return super.onTouchEvent(ev);
}
 
開發者ID:godness84,項目名稱:react-native-recyclerview-list,代碼行數:21,代碼來源:RecyclerViewBackedScrollView.java

示例6: onTouch

@Override
public boolean onTouch(View v, MotionEvent event) {

    ImageView view = (ImageView) v;
    switch (event.getAction() & MotionEvent.ACTION_MASK) {
        case MotionEvent.ACTION_DOWN:
            savedMatrix.set(matrix);
            start.set(event.getX(), event.getY());
            Log.d(TAG, "mode=DRAG");
            mode = DRAG;
            break;
        case MotionEvent.ACTION_POINTER_DOWN:
            oldDist = spacing(event);
            Log.d(TAG, "oldDist=" + oldDist);
            if (oldDist > 10f) {
                savedMatrix.set(matrix);
                midPoint(mid, event);
                mode = ZOOM;
                Log.d(TAG, "mode=ZOOM");
            }
            break;
        case MotionEvent.ACTION_MOVE:
            /*  *//*  if (mode == DRAG) {
                matrix.set(savedMatrix);
                matrix.postTranslate(event.getX() - start.x, event.getY() - start.y);
            }*//*
            else*/
            if (mode == ZOOM) {
                float newDist = spacing(event);
                Log.d(TAG, "newDist=" + newDist);
                if (newDist > 10f) {
                    matrix.set(savedMatrix);
                    float scale = newDist / oldDist;
                    matrix.postScale(scale, scale, mid.x, mid.y);
                }
            }
            break;
        case MotionEvent.ACTION_UP:
        case MotionEvent.ACTION_POINTER_UP:
            mode = NONE;
            Log.d(TAG, "mode=NONE");
            break;
    }
    // Perform the transformation
    view.setImageMatrix(matrix);
    return true; // indicate event was handled
}
 
開發者ID:sega4revenge,項目名稱:Sega,代碼行數:47,代碼來源:Fullscreen.java

示例7: saveTouchCoords

private void saveTouchCoords(MotionEvent ev) {
    int action = ev.getAction() & MotionEvent.ACTION_MASK;
    if (action != MotionEvent.ACTION_DOWN) {
        mLastX = mX;
        mLastY = mY;
    }
    mX = (int) ev.getX();
    mY = (int) ev.getY();
    if (action == MotionEvent.ACTION_DOWN) {
        mLastX = mX;
        mLastY = mY;
    }
    mOffsetX = (int) ev.getRawX() - mX;
    mOffsetY = (int) ev.getRawY() - mY;
}
 
開發者ID:ultrasonic,項目名稱:ultrasonic,代碼行數:15,代碼來源:DragSortListView.java

示例8: 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:benniaobuguai,項目名稱:android-project-gallery,代碼行數:33,代碼來源:EclairGestureDetector.java

示例9: handleMotionEvent

private float[] handleMotionEvent(MotionEvent event) {
	switch (event.getAction() & MotionEvent.ACTION_MASK) {
	case MotionEvent.ACTION_DOWN:
		last = new PointF(event.getX(0), event.getY(0));
		break;
	case MotionEvent.ACTION_MOVE:
	case MotionEvent.ACTION_UP:
		PointF curr = new PointF(event.getX(0), event.getY(0));
		return new float[] { curr.x - last.x, curr.y - last.y };

	}
	return null;
}
 
開發者ID:SavorGit,項目名稱:Hotspot-master-devp,代碼行數:13,代碼來源:ImageShowViewPager.java

示例10: dispatchTouchEvent

@Override
public boolean dispatchTouchEvent(MotionEvent event) {
    final int action = event.getAction() & MotionEvent.ACTION_MASK;
    switch (action) {
        case MotionEvent.ACTION_CANCEL:
        case MotionEvent.ACTION_UP:
            removeAllCallbacks();
            break;
    }
    return super.dispatchTouchEvent(event);
}
 
開發者ID:helenepang,項目名稱:LimitedDatePicker,代碼行數:11,代碼來源:NumberPicker.java

示例11: isArrowButtonPressed

private boolean isArrowButtonPressed(boolean currentPressedState, MotionEvent event){
    boolean isPressed = currentPressedState;
    if((event.getAction() & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_DOWN) {
        isPressed = true;
    }
    if((event.getAction() & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_UP) {
        isPressed = false;
    }
    return isPressed;
}
 
開發者ID:zugaldia,項目名稱:android-robocar,代碼行數:10,代碼來源:GameControllerActivity.java

示例12: onTouchEvent

@Override
public boolean onTouchEvent(MotionEvent ev) {
  if (!mScrollEnabled) {
    return false;
  }

  int action = ev.getAction() & MotionEvent.ACTION_MASK;
  if (action == MotionEvent.ACTION_UP && mDragging) {
    ReactScrollViewHelper.emitScrollEndDragEvent(this);
    mDragging = false;
    disableFpsListener();
  }
  return super.onTouchEvent(ev);
}
 
開發者ID:qq565999484,項目名稱:RNLearn_Project1,代碼行數:14,代碼來源:ReactScrollView.java

示例13: 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:fengdongfei,項目名稱:CXJPadProject,代碼行數:28,代碼來源:VersionedGestureDetector.java

示例14: onTouchEvent

@Override
public boolean onTouchEvent(MotionEvent event) {
    final int action = event.getAction();

    /*
     * Switch on the action. The action is extracted from the event by
     * applying the MotionEvent.ACTION_MASK. Alternatively a call to
     * event.getActionMasked() would yield in the action as well.
     */
    switch (action & MotionEvent.ACTION_MASK) {
        case MotionEvent.ACTION_POINTER_DOWN: { // 類似上麵,但是這邊還不是最後一點
            pressLine = 0;
            break;
        }
        case MotionEvent.ACTION_UP: { // 手指離開,視為最後一點離開
            mHasTouch = false;
            pressLine = 0;
            break;
        }
        case MotionEvent.ACTION_POINTER_UP: { // 類似上麵,但是這邊還不是最後一點
            pressLine = 0;
            break;
        }

        case MotionEvent.ACTION_DOWN: { // 手指按下去, 這個事件隻有單點,視為第1點
            mHasTouch = true;

            double x, y, dl, dr, abs;
            double a, b, c;

            x = event.getX();
            y = event.getY();
            a = (cP.y - cA.y);
            b = -(cP.x - cA.x);
            c = -(a * cA.x + b*cA.y);
            abs = Math.sqrt(a*a+b*b);
            dl = Math.abs(a*x + b*y + c)/abs;

            a = (cP.y - cB.y);
            b = (cB.x - cP.x);
            c = -(a * cB.x + b*cB.y); // (cB.y * (cP.x - cB.x) + cB.x * (cB.y - cP.y));
            abs = Math.sqrt(a*a+b*b);
            dr = Math.abs(a*x + b*y + c)/abs;

            if      (dl < 20 && 20 < dr) pressLine = 1;
            else if (dl > 20 && 20 > dr) pressLine = 2;
            else pressLine = 0;
            break;
        }

        case MotionEvent.ACTION_MOVE: { // 用來實現放大縮小,放遠放近, 在按第二點以上時,通常會產生一堆 ACTION_MOVE
            if (pressLine > 0) {
                double x, y, Vx, Vy, len, cos, acos;

                x = event.getX();
                y = event.getY();
                if (pressLine == 1) {
                    Vx = x - cA.x;
                    Vy = y - cA.y;
                } else {
                    Vx = x - cB.x;
                    Vy = y - cB.y;
                }
                len = Math.sqrt(Vx*Vx + Vy*Vy);
                cos = -Vx / len;
                if (cos < -1 && cos > -2) cos = -1;
                else if (cos > 1 && cos < 2) cos = 1;
                acos = Math.acos(cos);
                if (pressLine == 1) mainActivity.angleA = acos;
                else mainActivity.angleB = acos;
                calcP();
                save();
            }
            break;
        }
    }

    // trigger redraw on UI thread
    this.postInvalidate();
    return true;
}
 
開發者ID:wade-fs,項目名稱:Military-North-Compass,代碼行數:81,代碼來源:TriangleView.java

示例15: handleItemDragEvent

public boolean handleItemDragEvent(MotionEvent event){
    switch (event.getAction() & MotionEvent.ACTION_MASK) {
        case MotionEvent.ACTION_DOWN:
            mDownX = (int)event.getRawX();
            mDownY = (int)event.getRawY();
            break;
        case MotionEvent.ACTION_MOVE:
            if(mDownY == -1){
                mDownY = (int)event.getRawY();

            }
            if(mDownX == -1){
                mDownX = (int)event.getRawX();
            }
            if(mScrollDownY == -1){
                mScrollDownY = mRootLayout.getScrollY();
            }

            mLastEventX = (int) event.getRawX();
            mLastEventY = (int) event.getRawY();
            int deltaX = mLastEventX - mDownX;
            int deltaY = mLastEventY - mDownY;

            if (mCellIsMobile) {
                int location[] = new int[2];
                mobileView.getLocationOnScreen(location);
                int root_location[] = new int[2];
                mRootLayout.getLocationOnScreen(root_location);
                int offsetX = deltaX-root_location[0];
                int offsetY = location[1]+deltaY-root_location[1]+mRootLayout.getScrollY()-mScrollDownY;
                mHoverCellCurrentBounds.offsetTo(offsetX,
                        offsetY);
                mHoverCell.setBounds(rotatedBounds(mHoverCellCurrentBounds,0.0523599f));
                invalidate();
                handleItemDrag();
                return true;
            }
            break;
        case MotionEvent.ACTION_UP:
            touchEventsCancelled();
            break;
        case MotionEvent.ACTION_CANCEL:
            touchEventsCancelled();
            break;
        case MotionEvent.ACTION_POINTER_UP:
            break;
        default:
            break;
    }
    return false;
}
 
開發者ID:tangqipeng,項目名稱:draggable-tree-itemview,代碼行數:51,代碼來源:DraggableTreeView.java


注:本文中的android.view.MotionEvent.ACTION_MASK屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。