use of com.google.android.maps.Overlay in project robolectric by robolectric.
the class ShadowMapView method dispatchTouchEvent.
@Implementation
public boolean dispatchTouchEvent(MotionEvent event) {
for (Overlay overlay : overlays) {
if (overlay.onTouchEvent(event, realMapView)) {
return true;
}
}
GeoPoint mouseGeoPoint = getProjection().fromPixels((int) event.getX(), (int) event.getY());
int diffX = 0;
int diffY = 0;
if (mouseDownOnMe) {
diffX = (int) event.getX() - lastTouchEventPoint.x;
diffY = (int) event.getY() - lastTouchEventPoint.y;
}
switch(event.getAction()) {
case MotionEvent.ACTION_DOWN:
mouseDownOnMe = true;
mouseDownCenter = getMapCenter();
break;
case MotionEvent.ACTION_MOVE:
if (mouseDownOnMe) {
moveByPixels(-diffX, -diffY);
}
break;
case MotionEvent.ACTION_UP:
if (mouseDownOnMe) {
moveByPixels(-diffX, -diffY);
mouseDownOnMe = false;
}
break;
case MotionEvent.ACTION_CANCEL:
getController().setCenter(mouseDownCenter);
mouseDownOnMe = false;
break;
}
lastTouchEventPoint = new Point((int) event.getX(), (int) event.getY());
return realView.dispatchTouchEvent(event);
}
Aggregations