本文整理汇总了Java中org.oscim.event.MotionEvent.ACTION_UP属性的典型用法代码示例。如果您正苦于以下问题:Java MotionEvent.ACTION_UP属性的具体用法?Java MotionEvent.ACTION_UP怎么用?Java MotionEvent.ACTION_UP使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.oscim.event.MotionEvent
的用法示例。
在下文中一共展示了MotionEvent.ACTION_UP属性的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onInputEvent
@Override
public void onInputEvent(Event e, MotionEvent motionEvent) {
int action = motionEvent.getAction();
if (action == MotionEvent.ACTION_DOWN) {
downX = motionEvent.getX() - mMap.getWidth() / 2;
downY = motionEvent.getY() - mMap.getHeight() / 2;
}
if (mActiveMarker == null)
return;
if (action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_CANCEL) {
// Update corresponding waypoint
Waypoint waypoint = (Waypoint) mActiveMarker.getUid();
waypoint.setCoordinates(mActiveMarker.getPoint());
onWaypointSave(waypoint);
mActiveMarker = null;
// Unshift map to its original position
mMap.animator().animateTo(MAP_POSITION_ANIMATION_DURATION / 2, mMap.viewport().fromScreenPoint(mMap.getWidth() / 2, mMap.getHeight() / 2 - mFingerTipSize), 1, true);
mMap.getEventLayer().enableMove(true);
} else if (action == MotionEvent.ACTION_MOVE) {
float eventX = motionEvent.getX() - deltaX;
float eventY = motionEvent.getY() - deltaY - 3 * mFingerTipSize;
mActiveMarker.setPoint(mMap.viewport().fromScreenPoint(eventX, eventY));
mMarkerLayer.updateItems();
mMap.updateMap(true);
}
}
示例2: onInputEvent
@Override
public void onInputEvent(Event event, MotionEvent motionEvent) {
if ((motionEvent.getAction() == MotionEvent.ACTION_CANCEL || motionEvent.getAction() == MotionEvent.ACTION_UP) && currentlyDraggedItem != null) {
currentlyDraggedItem.onDragStop();
currentlyDraggedItem = null;
}
if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) {
dragLastX = motionEvent.getX();
dragLastY = motionEvent.getY();
}
if (motionEvent.getAction() == MotionEvent.ACTION_MOVE && currentlyDraggedItem != null) {
Point out = new Point();
mapView.map().viewport().toScreenPoint(GmsMapsTypeHelper.fromLatLng(currentlyDraggedItem.getPosition()), out);
out.x += mapView.getWidth() / 2;
out.y += mapView.getHeight() / 2;
float mx = motionEvent.getX() - dragLastX;
float my = motionEvent.getY() - dragLastY;
currentlyDraggedItem.setPosition(GmsMapsTypeHelper.toLatLng(mapView.map().viewport().fromScreenPoint((float) out.getX() + mx, (float) out.getY() + my)));
currentlyDraggedItem.onDragProgress();
dragLastX += mx;
dragLastY += my;
}
}
示例3: touchUp
@Override
public boolean touchUp(int screenX, int screenY, int pointer, int button) {
if (pointer >= 10)
return true;
if (button != Buttons.LEFT)
return false;
if (mPointerDown == 0)
return true;
mTime = Gdx.input.getCurrentEventTime();
mType = (--mPointerDown == 0) ?
MotionEvent.ACTION_UP :
MotionEvent.ACTION_POINTER_UP;
mPointerX[pointer] = mCurX = screenX;
mPointerY[pointer] = mCurY = screenY;
mPointer = pointer;
//GdxMap.log.debug("up " + screenX + ":" + screenY
// + " / " + pointer + " " + mPointerDown
// + " " + (getTime() - mDownTime));
mMap.input.fire(null, this);
return true;
}
示例4: onTouchEvent
public boolean onTouchEvent(MotionEvent e) {
int action = getAction(e);
if (action == MotionEvent.ACTION_DOWN) {
mMap.animator().cancel();
mStartMove = -1;
mDoubleTap = false;
mDragZoom = false;
mPrevX1 = e.getX(0);
mPrevY1 = e.getY(0);
mDown = true;
return true;
}
if (!(mDown || mDoubleTap)) {
/* no down event received */
return false;
}
if (action == MotionEvent.ACTION_MOVE) {
onActionMove(e);
return true;
}
if (action == MotionEvent.ACTION_UP) {
mDown = false;
if (mDoubleTap && !mDragZoom) {
float pivotX = 0, pivotY = 0;
if (!mFixOnCenter) {
pivotX = mPrevX1 - mMap.getWidth() / 2;
pivotY = mPrevY1 - mMap.getHeight() / 2;
}
/* handle double tap zoom */
mMap.animator().animateZoom(300, 2, pivotX, pivotY);
} else if (mStartMove > 0) {
/* handle fling gesture */
mTracker.update(e.getX(), e.getY(), e.getTime());
float vx = mTracker.getVelocityX();
float vy = mTracker.getVelocityY();
/* reduce velocity for short moves */
float t = e.getTime() - mStartMove;
if (t < FLING_MIN_THREHSHOLD) {
t = t / FLING_MIN_THREHSHOLD;
vy *= t * t;
vx *= t * t;
}
doFling(vx, vy);
}
return true;
}
if (action == MotionEvent.ACTION_CANCEL) {
return false;
}
if (action == MotionEvent.ACTION_POINTER_DOWN) {
mStartMove = -1;
updateMulti(e);
return true;
}
if (action == MotionEvent.ACTION_POINTER_UP) {
updateMulti(e);
return true;
}
return false;
}
示例5: onInputEvent
@Override
public void onInputEvent(Event event, MotionEvent e) {
int action = e.getAction() & MotionEvent.ACTION_MASK;
if ((action == MotionEvent.ACTION_CANCEL)) {
cancel();
return;
}
if (mLongpressTimer != null) {
// any pointer up while long press detection
// cancels timer
if (action == MotionEvent.ACTION_POINTER_UP
|| action == MotionEvent.ACTION_UP) {
cancel();
return;
}
// two fingers must still be down, tested
// one above.
if (action == MotionEvent.ACTION_MOVE) {
// update pointer positions
// int idx1 = e.findPointerIndex(mPointer1);
// int idx2 = e.findPointerIndex(mPointer2);
mCurX1 = e.getX(0);
mCurY1 = e.getY(0);
mCurX2 = e.getX(1);
mCurY2 = e.getY(1);
// cancel if moved one finger more than 50 pixel
float maxSq = 10 * 10;
float d = (mCurX1 - mPrevX1) * (mCurX1 - mPrevX1)
+ (mCurY1 - mPrevY1) * (mCurY1 - mPrevY1);
if (d > maxSq) {
cancel();
return;
}
d = (mCurX2 - mPrevX2) * (mCurX2 - mPrevX2)
+ (mCurY2 - mPrevY2) * (mCurY2 - mPrevY2);
if (d > maxSq) {
cancel();
return;
}
}
}
if ((action == MotionEvent.ACTION_POINTER_DOWN)
&& (e.getPointerCount() == 2)) {
// App.log.debug("down");
// keep track of pointer ids, only
// use these for gesture, ignoring
// more than two pointer
// mPointer1 = e.getPointerId(0);
// mPointer2 = e.getPointerId(1);
if (mLongpressTimer == null) {
// start timer, keep initial down position
mCurX1 = mPrevX1 = e.getX(0);
mCurY1 = mPrevY1 = e.getY(0);
mCurX2 = mPrevX2 = e.getX(1);
mCurY2 = mPrevY2 = e.getY(1);
runLongpressTimer();
}
}
}