本文整理汇总了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;
}