本文整理了Java中android.view.MotionEvent.getActionIndex()
方法的一些代码示例,展示了MotionEvent.getActionIndex()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MotionEvent.getActionIndex()
方法的具体详情如下:
包路径:android.view.MotionEvent
类名称:MotionEvent
方法名:getActionIndex
暂无
代码示例来源:origin: steelkiwi/cropiwa
private void onPointerUp(MotionEvent ev) {
int id = ev.getPointerId(ev.getActionIndex());
fingerToCornerMapping.remove(id);
}
代码示例来源:origin: steelkiwi/cropiwa
private void onPointerUp(MotionEvent e) {
//If user lifted finger that we used to calculate translation, we need to find a new one
if (e.getPointerId(e.getActionIndex()) == id) {
int index = 0;
while (index < e.getPointerCount() && index == e.getActionIndex()) {
index++;
}
onDown(e.getX(index), e.getY(index), e.getPointerId(index));
}
}
代码示例来源:origin: mxn21/FlowingDrawer
private void onPointerUp(MotionEvent ev) {
final int pointerIndex = ev.getActionIndex();
final int pointerId = ev.getPointerId(pointerIndex);
if (pointerId == mActivePointerId) {
final int newPointerIndex = pointerIndex == 0 ? 1 : 0;
mLastMotionX = ev.getX(newPointerIndex);
mActivePointerId = ev.getPointerId(newPointerIndex);
if (mVelocityTracker != null) {
mVelocityTracker.clear();
}
}
}
代码示例来源:origin: steelkiwi/cropiwa
/**
* @return {@literal true} if ev.x && ev.y are in area of some corner point
*/
private boolean tryAssociateWithCorner(MotionEvent ev) {
int index = ev.getActionIndex();
return tryAssociateWithCorner(
ev.getPointerId(index),
ev.getX(index), ev.getY(index));
}
代码示例来源:origin: steelkiwi/cropiwa
private void onStartGesture(MotionEvent ev) {
//Does user want to resize the crop area?
if (tryAssociateWithCorner(ev)) {
return;
}
//Does user want to drag the crop area?
int index = ev.getActionIndex();
if (cropRect.contains(ev.getX(index), ev.getY(index))) {
cropDragStartPoint = new PointF(ev.getX(index), ev.getY(index));
cropRectBeforeDrag = new RectF(cropRect);
}
}
代码示例来源: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 trySecondFingerClick(MotionEvent event) {
if (mSecondFingerPointerId == event.getPointerId(event.getActionIndex())) {
updateSecondFinger(event);
AbstractFlashcardViewer cardViewer = mCardViewer.get();
if (mSecondFingerWithinTapTolerance && cardViewer != null) {
cardViewer.tapOnCurrentCard((int) mSecondFingerX, (int) mSecondFingerY);
return true;
}
}
return false;
}
代码示例来源:origin: PhilJay/MPAndroidChart
public static void velocityTrackerPointerUpCleanUpIfNecessary(MotionEvent ev,
VelocityTracker tracker) {
// Check the dot product of current velocities.
// If the pointer that left was opposing another velocity vector, clear.
tracker.computeCurrentVelocity(1000, mMaximumFlingVelocity);
final int upIndex = ev.getActionIndex();
final int id1 = ev.getPointerId(upIndex);
final float x1 = tracker.getXVelocity(id1);
final float y1 = tracker.getYVelocity(id1);
for (int i = 0, count = ev.getPointerCount(); i < count; i++) {
if (i == upIndex)
continue;
final int id2 = ev.getPointerId(i);
final float x = x1 * tracker.getXVelocity(id2);
final float y = y1 * tracker.getYVelocity(id2);
final float dot = x + y;
if (dot < 0) {
tracker.clear();
break;
}
}
}
代码示例来源:origin: liaoinstan/SpringView
switch (action) {
case MotionEvent.ACTION_DOWN: {
final int pointerIndex = ev.getActionIndex();
final float x = ev.getX(pointerIndex);
final float y = ev.getY(pointerIndex);
break;
case MotionEvent.ACTION_POINTER_DOWN: {
final int pointerIndex = ev.getActionIndex();
final int pointerId = ev.getPointerId(pointerIndex);
if (pointerId != mActivePointerId) {
final int pointerIndex = ev.getActionIndex();
final int pointerId = ev.getPointerId(pointerIndex);
if (pointerId == mActivePointerId) {
代码示例来源:origin: Yalantis/uCrop
fX = event.getX();
fY = event.getY();
mPointerIndex2 = event.findPointerIndex(event.getPointerId(event.getActionIndex()));
mAngle = 0;
mIsFirstTouch = true;
代码示例来源:origin: k9mail/k-9
private boolean isEventOverChild(MotionEvent ev, List<View> children) {
final int actionIndex = ev.getActionIndex();
final float x = ev.getX(actionIndex) + getScrollX();
final float y = ev.getY(actionIndex) + getScrollY();
for (View child : children) {
if (!canViewReceivePointerEvents(child)) {
continue;
}
child.getHitRect(sHitFrame);
// child can receive the motion event.
if (sHitFrame.contains((int) x, (int) y)) {
return true;
}
}
return false;
}
代码示例来源:origin: davemorrissey/subsampling-scale-image-view
switch (event.getActionMasked()) {
case MotionEvent.ACTION_DOWN:
if (event.getActionIndex() == 0) {
vStart = new PointF(event.getX(), event.getY());
vPrevious = new PointF(event.getX(), event.getY());
代码示例来源:origin: jdamcd/android-crop
lastY = event.getY();
validPointerId = event.getPointerId(event.getActionIndex());
motionHighlightView.setMode((edge == HighlightView.MOVE)
? HighlightView.ModifyMode.Move
break;
case MotionEvent.ACTION_MOVE:
if (motionHighlightView != null && event.getPointerId(event.getActionIndex()) == validPointerId) {
motionHighlightView.handleMotion(motionEdge, event.getX()
- lastX, event.getY() - lastY);
代码示例来源:origin: stackoverflow.com
<pre>
final float[] getPointerCoords(ImageView view, MotionEvent e)
{
final int index = e.getActionIndex();
final float[] coords = new float[] { e.getX(index), e.getY(index) };
Matrix matrix = new Matrix();
view.getImageMatrix().invert(matrix);
matrix.postTranslate(view.getScrollX(), view.getScrollY());
matrix.mapPoints(coords);
return coords;
}
</pre>
代码示例来源:origin: stackoverflow.com
switch (event.getActionMasked()) {
case MotionEvent.ACTION_DOWN:
ptrID1 = event.getPointerId(event.getActionIndex());
break;
case MotionEvent.ACTION_POINTER_DOWN:
ptrID2 = event.getPointerId(event.getActionIndex());
sX = event.getX(event.findPointerIndex(ptrID1));
sY = event.getY(event.findPointerIndex(ptrID1));
代码示例来源:origin: robolectric/robolectric
@Test
public void canGetActionIndex() {
assertEquals(0, event.getActionIndex());
shadowMotionEvent.setPointerIndex(1);
assertEquals(1, event.getActionIndex());
}
代码示例来源:origin: aa112901/remusic
cancelEvent
.setAction(MotionEvent.ACTION_CANCEL
| (event.getActionIndex() << MotionEvent.ACTION_POINTER_INDEX_SHIFT));
v.onTouchEvent(cancelEvent);
代码示例来源:origin: jdsjlzx/LRecyclerView
break;
case MotionEvent.ACTION_POINTER_DOWN:
final int index = ev.getActionIndex();
mActivePointerId = ev.getPointerId(index);
mLastY = (int) ev.getY(index);
代码示例来源:origin: ZieIony/Carbon
break;
case MotionEvent.ACTION_POINTER_UP: {
final int pointerIndex = event.getActionIndex();
final int pointerId = event.getPointerId(pointerIndex);
if (pointerId == mActivePointerId) {
代码示例来源:origin: scwang90/SmartRefreshLayout
final int skipIndex = pointerUp ? e.getActionIndex() : -1;
内容来源于网络,如有侵权,请联系作者删除!