当前位置: 首页>>代码示例>>Java>>正文


Java MotionEvent.getAction方法代码示例

本文整理汇总了Java中org.oscim.event.MotionEvent.getAction方法的典型用法代码示例。如果您正苦于以下问题:Java MotionEvent.getAction方法的具体用法?Java MotionEvent.getAction怎么用?Java MotionEvent.getAction使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.oscim.event.MotionEvent的用法示例。


在下文中一共展示了MotionEvent.getAction方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onInputEvent

import org.oscim.event.MotionEvent; //导入方法依赖的package包/类
@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);
    }
}
 
开发者ID:andreynovikov,项目名称:trekarta,代码行数:27,代码来源:MainActivity.java

示例2: onInputEvent

import org.oscim.event.MotionEvent; //导入方法依赖的package包/类
@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;
    }
}
 
开发者ID:microg,项目名称:android_packages_apps_GmsCore,代码行数:24,代码来源:BackendMap.java

示例3: getAction

import org.oscim.event.MotionEvent; //导入方法依赖的package包/类
private static int getAction(MotionEvent e) {
	return e.getAction() & MotionEvent.ACTION_MASK;
}
 
开发者ID:opensciencemap,项目名称:vtm,代码行数:4,代码来源:MapEventLayer.java

示例4: onInputEvent

import org.oscim.event.MotionEvent; //导入方法依赖的package包/类
@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();
		}
	}
}
 
开发者ID:opensciencemap,项目名称:vtm-app,代码行数:71,代码来源:DistanceTouchOverlay.java


注:本文中的org.oscim.event.MotionEvent.getAction方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。