本文整理了Java中android.view.MotionEvent.getPointerId()
方法的一些代码示例,展示了MotionEvent.getPointerId()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MotionEvent.getPointerId()
方法的具体详情如下:
包路径:android.view.MotionEvent
类名称:MotionEvent
方法名:getPointerId
暂无
代码示例来源:origin: TonicArtos/StickyGridHeaders
private static int[] getPointerIds(MotionEvent e) {
int n = e.getPointerCount();
int[] r = new int[n];
for (int i = 0; i < n; i++) {
r[i] = e.getPointerId(i);
}
return r;
}
代码示例来源:origin: novoda/android-demos
private void updatePointerId(MotionEvent ev) {
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;
mLastTouchX = ev.getX(newPointerIndex);
mLastTouchY = ev.getY(newPointerIndex);
mActivePointerId = ev.getPointerId(newPointerIndex);
}
}
代码示例来源:origin: robolectric/robolectric
public void set(MotionEvent event) {
pointerCount = event.getPointerCount();
pointerIds = new int[pointerCount];
x.clear();
y.clear();
for (int i = 0; i < pointerCount; i++) {
pointerIds[i] = event.getPointerId(i);
x.put(pointerIds[i], event.getX(i));
y.put(pointerIds[i], event.getY(i));
}
activePointerId = event.getPointerId(0);
eventTime = event.getEventTime();
}
代码示例来源:origin: stackoverflow.com
import android.view.MotionEvent;
public class EclairMotionEvent extends WrapMotionEvent {
protected EclairMotionEvent(MotionEvent event) {
super(event);
}
public float getX(int pointerIndex) {
return event.getX(pointerIndex);
}
public float getY(int pointerIndex) {
return event.getY(pointerIndex);
}
public int getPointerCount() {
return event.getPointerCount();
}
public int getPointerId(int pointerIndex) {
return event.getPointerId(pointerIndex);
}
}
代码示例来源:origin: novoda/android-demos
public void setMultitouchPoints(MotionEvent event) {
touchPoints.clear();
int pointerIndex = 0;
for (int index = 0; index < event.getPointerCount(); ++index) {
pointerIndex = event.getPointerId(index);
touchPoints.add(new PointF(event.getX(pointerIndex), event.getY(pointerIndex)));
}
}
代码示例来源:origin: novoda/android-demos
public void setInitalPositionMultiPoints(MotionEvent event) {
touchPoints.clear();
int pointerIndex = 0;
for (int index = 0; index < event.getPointerCount(); ++index) {
pointerIndex = event.getPointerId(index);
touchPoints.add(new PointF(event.getX(pointerIndex), event.getY(pointerIndex)));
}
double r = Math.atan2(touchPoints.get(1).x - touchPoints.get(1 - 1).x,
touchPoints.get(1).y - touchPoints.get(1 - 1).y);
old_degrees = -(int) Math.toDegrees(r);
}
代码示例来源:origin: chentao0707/SimplifyReader
private void onSecondaryPointerUp(MotionEvent ev) {
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.
// TODO: Make this decision more intelligent.
final int newPointerIndex = pointerIndex == 0 ? 1 : 0;
mMotionX = (int) ev.getX(newPointerIndex);
mMotionY = (int) ev.getY(newPointerIndex);
mActivePointerId = ev.getPointerId(newPointerIndex);
if (mVelocityTracker != null) {
mVelocityTracker.clear();
}
}
}
代码示例来源: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: jMonkeyEngine/jmonkeyengine
protected int getPointerId(MotionEvent event) {
return event.getPointerId(getPointerIndex(event));
}
代码示例来源:origin: steelkiwi/cropiwa
private void onPointerUp(MotionEvent ev) {
int id = ev.getPointerId(ev.getActionIndex());
fingerToCornerMapping.remove(id);
}
代码示例来源:origin: steelkiwi/cropiwa
public void onDown(MotionEvent e) {
onDown(e.getX(), e.getY(), e.getPointerId(0));
}
代码示例来源:origin: TangoAgency/material-intro-screen
private void onSecondaryPointerUp(MotionEvent ev) {
final int pointerIndex = MotionEventCompat.getActionIndex(ev);
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;
mLastMotionX = ev.getX(newPointerIndex);
mActivePointerId = ev.getPointerId(newPointerIndex);
if (mVelocityTracker != null) {
mVelocityTracker.clear();
}
}
}
代码示例来源: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: 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: 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: 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: libgdx/libgdx
public void onTouch (MotionEvent event, AndroidInput input) {
final int action = event.getAction() & MotionEvent.ACTION_MASK;
int pointerIndex = (event.getAction() & MotionEvent.ACTION_POINTER_INDEX_MASK) >> MotionEvent.ACTION_POINTER_INDEX_SHIFT;
int pointerId = event.getPointerId(pointerIndex);
for (int i = 0; i < pointerCount; i++) {
pointerIndex = i;
pointerId = event.getPointerId(pointerIndex);
x = (int)event.getX(pointerIndex);
y = (int)event.getY(pointerIndex);
代码示例来源:origin: robolectric/robolectric
@Test
public void canSetPointerIdsByIndex() {
shadowMotionEvent.setPointer2(20.0f, 30.0f);
shadowMotionEvent.setPointerIds(2, 5);
assertEquals(2, event.getPointerId(0));
assertEquals(5, event.getPointerId(1));
}
代码示例来源:origin: EverythingMe/overscroll-decor
@Override
public boolean handleMoveTouchEvent(MotionEvent event) {
final View view = mViewAdapter.getView();
if (!mMoveAttr.init(view, event)) {
return false;
}
// Has over-scrolling officially started?
if ((mViewAdapter.isInAbsoluteStart() && mMoveAttr.mDir) ||
(mViewAdapter.isInAbsoluteEnd() && !mMoveAttr.mDir)) {
// Save initial over-scroll attributes for future reference.
mStartAttr.mPointerId = event.getPointerId(0);
mStartAttr.mAbsOffset = mMoveAttr.mAbsOffset;
mStartAttr.mDir = mMoveAttr.mDir;
issueStateTransition(mOverScrollingState);
return mOverScrollingState.handleMoveTouchEvent(event);
}
return false;
}
内容来源于网络,如有侵权,请联系作者删除!