blob: fac5f9f5391429ddd0b2db996520a68aa55e8468 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
package com.xtremelabs.robolectric.shadows;
import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapController;
import com.xtremelabs.robolectric.internal.Implementation;
import com.xtremelabs.robolectric.internal.Implements;
/**
* A Shadow of {@code MapController} that tracks its own state and keeps the state of the {@code MapView} it controlls
* up to date.
*/
@SuppressWarnings({"UnusedDeclaration"})
@Implements(MapController.class)
public class ShadowMapController {
private ShadowMapView shadowMapView;
private GeoPoint geoPointAnimatedTo;
@Implementation
public void animateTo(com.google.android.maps.GeoPoint geoPoint) {
setCenter(geoPoint);
geoPointAnimatedTo = geoPoint;
}
@Implementation
public void animateTo(com.google.android.maps.GeoPoint geoPoint, java.lang.Runnable runnable) {
animateTo(geoPoint);
runnable.run();
}
@Implementation
public void setCenter(com.google.android.maps.GeoPoint geoPoint) {
shadowMapView.mapCenter = geoPoint;
}
@Implementation
public void zoomToSpan(int latSpan, int lngSpan) {
shadowMapView.latitudeSpan = latSpan;
shadowMapView.longitudeSpan = lngSpan;
}
@Implementation
public boolean zoomIn() {
shadowMapView.zoomLevel++;
return true;
}
@Implementation
public boolean zoomOut() {
shadowMapView.zoomLevel--;
return true;
}
@Implementation
public int setZoom(int i) {
shadowMapView.zoomLevel = i;
return i;
}
/**
* Non-Android accessor that returns the {@code MapView} that is being controlled
*
* @return the {@code MapView} that is being controlled
*/
public ShadowMapView getShadowMapView() {
return shadowMapView;
}
/**
* Non-Android accessor that returns the most recent value set by a call to either version of {@code animateTo()}
*
* @return the most recent value set by a call to either version of {@code animateTo()}
*/
public GeoPoint getGeoPointAnimatedTo() {
return geoPointAnimatedTo;
}
/**
* Non-Android accessor that allows the {@code MapView} being controlled to be set explicitly.
*
* @param shadowMapView the {@link ShadowMapView} to be controlled (either created explicitly or obtained via a call
* to {@link com.xtremelabs.robolectric.RobolectricForMaps.shadowOf(com.google.android.maps.MapView)})
*/
void setShadowMapView(ShadowMapView shadowMapView) {
this.shadowMapView = shadowMapView;
}
}
|