Search in sources :

Example 1 with Overlay

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);
}
Also used : GeoPoint(com.google.android.maps.GeoPoint) Point(android.graphics.Point) GeoPoint(com.google.android.maps.GeoPoint) Overlay(com.google.android.maps.Overlay) Point(android.graphics.Point) GeoPoint(com.google.android.maps.GeoPoint) Implementation(org.robolectric.annotation.Implementation)

Aggregations

Point (android.graphics.Point)1 GeoPoint (com.google.android.maps.GeoPoint)1 Overlay (com.google.android.maps.Overlay)1 Implementation (org.robolectric.annotation.Implementation)1