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


Java MotionEvent.INVALID_POINTER_ID屬性代碼示例

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


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

示例1: resetView

/**
 * Reset the view to the top-left corner of the virtual workspace (with a small margin), and
 * reset zoom to unit scale.
 * <p/>
 * This is called when the "reset view" button is clicked, or when
 * {@link #mResetViewPending} is set.
 */
public void resetView() {
    // Reset scrolling state.
    mPanningPointerId = MotionEvent.INVALID_POINTER_ID;
    mPanningStart.set(0,0);
    mOriginalScrollX = 0;
    mOriginalScrollY = 0;

    updateScaleStep(INIT_ZOOM_SCALES_INDEX);

    final Rect blocksBoundingBox = getViewScaledBlockBounds();
    final boolean useRtl = mWorkspaceView.getWorkspaceHelper().useRtl();
    if (mScrollable) {
        final int margin = mGridRenderer.getGridSpacing() / 2;
        final int scrollToY = blocksBoundingBox.top - margin;
        if (useRtl) {
            scrollTo(blocksBoundingBox.right - getMeasuredWidth() + margin, scrollToY);
        } else {
            scrollTo(blocksBoundingBox.left - margin, scrollToY);
        }
    } else {
        // Reset top leading corner to 0,0 when
        scrollTo(useRtl ? -getMeasuredWidth() : 0, 0);
    }
}
 
開發者ID:Axe-Ishmael,項目名稱:Blockly,代碼行數:31,代碼來源:VirtualWorkspaceView.java

示例2: reset

/**
 * Resets the component to the initial state.
 */
public void reset() {
  mGestureInProgress = false;
  mPointerCount = 0;
  for (int i = 0; i < MAX_POINTERS; i++) {
    mId[i] = MotionEvent.INVALID_POINTER_ID;
  }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:10,代碼來源:MultiPointerGestureDetector.java

示例3: updatePointersOnTap

private void updatePointersOnTap(MotionEvent event) {
  mPointerCount = 0;
  for (int i = 0; i < MAX_POINTERS; i++) {
    int index = getPressedPointerIndex(event, i);
    if (index == -1) {
      mId[i] = MotionEvent.INVALID_POINTER_ID;
    } else {
      mId[i] = event.getPointerId(index);
      mCurrentX[i] = mStartX[i] = event.getX(index);
      mCurrentY[i] = mStartY[i] = event.getY(index);
      mPointerCount++;
    }
  }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:14,代碼來源:MultiPointerGestureDetector.java

示例4: resetTouch

private void resetTouch() {
    mActivePointerId = MotionEvent.INVALID_POINTER_ID;
    mIsDragging = false;
    mOpenOnClick = false;
    mInitialTouchX = mInitialTouchY = mLastTouchY = 0;
    mVelocityTracker.clear();
}
 
開發者ID:RikkaW,項目名稱:Bridge,代碼行數:7,代碼來源:ResolverDrawerLayout.java

示例5: reset

/**
 * Resets the component to the initial state.
 */
public void reset() {
    mGestureInProgress = false;
    mPointerCount = 0;
    for (int i = 0; i < MAX_POINTERS; i++) {
        mId[i] = MotionEvent.INVALID_POINTER_ID;
    }
}
 
開發者ID:ibosong,項目名稱:CommentGallery,代碼行數:10,代碼來源:MultiPointerGestureDetector.java

示例6: updatePointersOnTap

private void updatePointersOnTap(MotionEvent event) {
    mPointerCount = 0;
    for (int i = 0; i < MAX_POINTERS; i++) {
        int index = getPressedPointerIndex(event, i);
        if (index == -1) {
            mId[i] = MotionEvent.INVALID_POINTER_ID;
        } else {
            mId[i] = event.getPointerId(index);
            mCurrentX[i] = mStartX[i] = event.getX(index);
            mCurrentY[i] = mStartY[i] = event.getY(index);
            mPointerCount++;
        }
    }
}
 
開發者ID:ibosong,項目名稱:CommentGallery,代碼行數:14,代碼來源:MultiPointerGestureDetector.java

示例7: reset

/**
 * Resets the component to the initial state.
 */
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
public void reset() {
  mGestureInProgress = false;
  mCount = 0;
  for (int i = 0; i < MAX_POINTERS; i++) {
    mId[i] = Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH ?
            -1 : MotionEvent.INVALID_POINTER_ID;
  }
}
 
開發者ID:mingdroid,項目名稱:tumbviewer,代碼行數:12,代碼來源:MultiPointerGestureDetector.java

示例8: reset

/**
 * Resets the component to the initial state.
 */
public void reset() {
  mGestureInProgress = false;
  mCount = 0;
  for (int i = 0; i < MAX_POINTERS; i++) {
    mId[i] = MotionEvent.INVALID_POINTER_ID;
  }
}
 
開發者ID:sciage,項目名稱:FinalProject,代碼行數:10,代碼來源:MultiPointerGestureDetector.java

示例9: findIndex

private int findIndex(int pointerId) {
    for (int i = 0; i < mDownPointers; i++) {
        if (mDownPointerId[i] == pointerId) {
            return i;
        }
    }
    if (mDownPointers == MAX_TRACKED_POINTERS || pointerId == MotionEvent.INVALID_POINTER_ID) {
        return UNTRACKED_POINTER;
    }
    mDownPointerId[mDownPointers++] = pointerId;
    return mDownPointers - 1;
}
 
開發者ID:EggUncle,項目名稱:XposedNavigationBar,代碼行數:12,代碼來源:GesturesListener.java

示例10: handlerInterceptTouchEvent

private boolean handlerInterceptTouchEvent(MotionEvent ev, boolean isHead) {
    final int action = ev.getActionMasked();
    boolean mIsBeingDragged = false;
    switch (action) {
        case MotionEvent.ACTION_DOWN:
            mActivePointerId = ev.getPointerId(0);
            mIsBeingDragged = false;
            final float initialMotionY = ev.getY(mActivePointerId);
            if (initialMotionY == -1) {
                return false;
            }
            mInitialMotionX = ev.getX(mActivePointerId);
            mInitialMotionY = initialMotionY;
            break;
        case MotionEvent.ACTION_MOVE:
            if (mActivePointerId == MotionEvent.INVALID_POINTER_ID) {
                return false;
            }
            final int index = ev.findPointerIndex(mActivePointerId);
            if (index < 0) {
                return false;
            }
            final float y = ev.getY(mActivePointerId);
            final float x = ev.getX(mActivePointerId);

            if (y == -1) {
                return false;
            }
            float yDiff = y - mInitialMotionY;
            float xDiff = x - mInitialMotionX;
            if (!isHead)
                yDiff = -yDiff;
            if (yDiff > touchSlop && Math.abs(yDiff) > Math.abs(xDiff)) {
                mInitialMotionY = y;//觸發拖曳 刷新下Y值
                mIsBeingDragged = true;
            }
            break;
        case MotionEvent.ACTION_UP:
        case MotionEvent.ACTION_CANCEL:
            mIsBeingDragged = false;
            mActivePointerId = MotionEvent.INVALID_POINTER_ID;
            break;
        case MotionEvent.ACTION_POINTER_UP://兼容多個手指
            final int pointerIndex = ev.getActionIndex();
            final int pointerId = ev.getPointerId(pointerIndex);
            if (pointerId == mActivePointerId) {
                final int newPointerIndex = pointerIndex == 0 ? 1 : 0;
                mActivePointerId = ev.getPointerId(newPointerIndex);
            }
            break;
    }
    return mIsBeingDragged;
}
 
開發者ID:tohodog,項目名稱:QSRefreshLayout,代碼行數:53,代碼來源:QSBaseRefreshLayout.java


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