コード例 #1
0
  private void initMotionEvent(MotionEvent m) {
    mAction = m.getAction();
    mTime = (System.currentTimeMillis() - SystemClock.elapsedRealtime()) + m.getEventTime();
    mMetaState = m.getMetaState();

    switch (mAction & MotionEvent.ACTION_MASK) {
      case MotionEvent.ACTION_CANCEL:
      case MotionEvent.ACTION_UP:
      case MotionEvent.ACTION_POINTER_UP:
      case MotionEvent.ACTION_POINTER_DOWN:
      case MotionEvent.ACTION_DOWN:
      case MotionEvent.ACTION_MOVE:
      case MotionEvent.ACTION_HOVER_ENTER:
      case MotionEvent.ACTION_HOVER_MOVE:
      case MotionEvent.ACTION_HOVER_EXIT:
        {
          mCount = m.getPointerCount();
          mPoints = new Point[mCount];
          mPointIndicies = new int[mCount];
          mOrientations = new float[mCount];
          mPressures = new float[mCount];
          mPointRadii = new Point[mCount];
          mPointerIndex =
              (mAction & MotionEvent.ACTION_POINTER_INDEX_MASK)
                  >> MotionEvent.ACTION_POINTER_INDEX_SHIFT;
          for (int i = 0; i < mCount; i++) {
            addMotionPoint(i, i, m);
          }
          break;
        }
      default:
        {
          mCount = 0;
          mPointerIndex = -1;
          mPoints = new Point[mCount];
          mPointIndicies = new int[mCount];
          mOrientations = new float[mCount];
          mPressures = new float[mCount];
          mPointRadii = new Point[mCount];
        }
    }
  }