本文整理了Java中android.view.MotionEvent.findPointerIndex()
方法的一些代码示例,展示了MotionEvent.findPointerIndex()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MotionEvent.findPointerIndex()
方法的具体详情如下:
包路径:android.view.MotionEvent
类名称:MotionEvent
方法名:findPointerIndex
暂无
代码示例来源:origin: ankidroid/Anki-Android
private void reinitializeSecondFinger(MotionEvent event) {
mSecondFingerWithinTapTolerance = true;
mSecondFingerPointerId = event.getPointerId(event.getActionIndex());
mSecondFingerX0 = event.getX(event.findPointerIndex(mSecondFingerPointerId));
mSecondFingerY0 = event.getY(event.findPointerIndex(mSecondFingerPointerId));
}
代码示例来源:origin: ankidroid/Anki-Android
private boolean updateSecondFinger(MotionEvent event) {
int pointerIndex = event.findPointerIndex(mSecondFingerPointerId);
if (pointerIndex > -1) {
mSecondFingerX = event.getX(pointerIndex);
mSecondFingerY = event.getY(pointerIndex);
float dx = Math.abs(mSecondFingerX0 - mSecondFingerX);
float dy = Math.abs(mSecondFingerY0 - mSecondFingerY);
if (dx >= TOUCH_TOLERANCE || dy >= TOUCH_TOLERANCE) {
mSecondFingerWithinTapTolerance = false;
}
return true;
}
return false;
}
代码示例来源:origin: novoda/android-demos
public void updatePositionToMoveTheImage(MotionEvent event) {
final int pointerIndex = event.findPointerIndex(mActivePointerId);
final float x = event.getX(pointerIndex);
final float y = event.getY(pointerIndex);
if (!mScaleDetector.isInProgress()) {
final float dx = x - mLastTouchX;
final float dy = y - mLastTouchY;
mPosX += dx;
mPosY += dy;
invalidate();
}
mLastTouchX = x;
mLastTouchY = y;
}
代码示例来源:origin: jiangqqlmj/FastDev4Android
@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);
}
}
代码示例来源:origin: wangdan/AisenWeiBo
@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);
}
}
代码示例来源:origin: stackoverflow.com
case MotionEvent.ACTION_POINTER_DOWN:
ptrID2 = event.getPointerId(event.getActionIndex());
sX = event.getX(event.findPointerIndex(ptrID1));
sY = event.getY(event.findPointerIndex(ptrID1));
fX = event.getX(event.findPointerIndex(ptrID2));
fY = event.getY(event.findPointerIndex(ptrID2));
break;
case MotionEvent.ACTION_MOVE:
if(ptrID1 != INVALID_POINTER_ID && ptrID2 != INVALID_POINTER_ID){
float nfX, nfY, nsX, nsY;
nsX = event.getX(event.findPointerIndex(ptrID1));
nsY = event.getY(event.findPointerIndex(ptrID1));
nfX = event.getX(event.findPointerIndex(ptrID2));
nfY = event.getY(event.findPointerIndex(ptrID2));
代码示例来源:origin: Yalantis/uCrop
sX = event.getX();
sY = event.getY();
mPointerIndex1 = event.findPointerIndex(event.getPointerId(0));
mAngle = 0;
mIsFirstTouch = true;
fX = event.getX();
fY = event.getY();
mPointerIndex2 = event.findPointerIndex(event.getPointerId(event.getActionIndex()));
mAngle = 0;
mIsFirstTouch = true;
代码示例来源:origin: liaoinstan/SpringView
final int pointerIndex = ev.findPointerIndex(mActivePointerId);
final float x = ev.getX(pointerIndex);
final float y = ev.getY(pointerIndex);
代码示例来源:origin: steelkiwi/cropiwa
public void onTouchEvent(MotionEvent e, boolean canHandle) {
switch (e.getActionMasked()) {
case MotionEvent.ACTION_POINTER_UP:
onPointerUp(e);
return;
case MotionEvent.ACTION_MOVE:
break;
default:
return;
}
int index = e.findPointerIndex(id);
updateImageBounds();
float currentX = interpolator.interpolateX(e.getX(index));
float currentY = interpolator.interpolateY(e.getY(index));
if (canHandle) {
translateImage(currentX - prevX, currentY - prevY);
}
saveCoordinates(currentX, currentY);
}
代码示例来源:origin: chrisbanes/PhotoView
.findPointerIndex(mActivePointerId != INVALID_POINTER_ID ? mActivePointerId
: 0);
return true;
代码示例来源:origin: ZieIony/Carbon
private ViewHolder findSwipedView(MotionEvent motionEvent) {
final RecyclerView.LayoutManager lm = mRecyclerView.getLayoutManager();
if (mActivePointerId == ACTIVE_POINTER_ID_NONE) {
return null;
}
final int pointerIndex = motionEvent.findPointerIndex(mActivePointerId);
final float dx = motionEvent.getX(pointerIndex) - mInitialTouchX;
final float dy = motionEvent.getY(pointerIndex) - mInitialTouchY;
final float absDx = Math.abs(dx);
final float absDy = Math.abs(dy);
if (absDx < mSlop && absDy < mSlop) {
return null;
}
if (absDx > absDy && lm.canScrollHorizontally()) {
return null;
} else if (absDy > absDx && lm.canScrollVertically()) {
return null;
}
View child = findChildView(motionEvent);
if (child == null) {
return null;
}
return mRecyclerView.getChildViewHolder(child);
}
代码示例来源:origin: rey5137/material
break;
case MotionEvent.ACTION_MOVE:
final int activePointerIndex = srcEvent.findPointerIndex(mActivePointerId);
if (activePointerIndex >= 0) {
final float x = srcEvent.getX(activePointerIndex);
代码示例来源:origin: robolectric/robolectric
@Test
public void canFindPointerIndexFromId() {
shadowMotionEvent.setPointer2(20.0f, 30.0f);
shadowMotionEvent.setPointerIds(2, 1);
assertEquals(0, event.findPointerIndex(2));
assertEquals(1, event.findPointerIndex(1));
assertEquals(-1, event.findPointerIndex(3));
}
}
代码示例来源:origin: chentao0707/SimplifyReader
switch (mTouchMode) {
case TOUCH_MODE_DOWN:
final int pointerIndex = ev.findPointerIndex(mActivePointerId);
final int y = (int) ev.getY(pointerIndex);
if (startScrollIfNeeded(y - mMotionY)) {
代码示例来源:origin: ZieIony/Carbon
final int index = e.findPointerIndex(mActivePointerId);
final float x = e.getX(index);
final float y = e.getY(index);
代码示例来源:origin: ZieIony/Carbon
final int index = event.findPointerIndex(mActivePointerId);
if (DEBUG) {
Log.d(TAG, "pointer index " + index);
代码示例来源:origin: jdsjlzx/LRecyclerView
break;
case MotionEvent.ACTION_MOVE:
int pointerIndex = ev.findPointerIndex(mActivePointerId);
if (pointerIndex == -1) {
pointerIndex = 0;
代码示例来源:origin: ZieIony/Carbon
final int activePointerIndex = event.findPointerIndex(mActivePointerId);
if (activePointerIndex >= 0) {
checkSelectForSwipe(action, event, activePointerIndex);
代码示例来源:origin: janishar/PlaceHolderView
if(!resetDone && event.findPointerIndex(activePointerId) != SwipeDecor.PRIMITIVE_NULL) {
y = event.getRawY();
FrameLayout.LayoutParams layoutParamsTemp = (FrameLayout.LayoutParams) v.getLayoutParams();
代码示例来源:origin: rey5137/material
final int activeIndex = event.findPointerIndex(activePointerId);
if (activeIndex < 0) {
handledEvent = false;
内容来源于网络,如有侵权,请联系作者删除!