本文整理匯總了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);
}
}
示例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;
}
}
示例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++;
}
}
}
示例4: resetTouch
private void resetTouch() {
mActivePointerId = MotionEvent.INVALID_POINTER_ID;
mIsDragging = false;
mOpenOnClick = false;
mInitialTouchX = mInitialTouchY = mLastTouchY = 0;
mVelocityTracker.clear();
}
示例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;
}
}
示例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++;
}
}
}
示例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;
}
}
示例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;
}
}
示例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;
}
示例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;
}