blob: 1291d3cbfe53316c96ae4e1f8e19aabf0270a842 (
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
|
package cgeo.geocaching.sensors;
import cgeo.geocaching.enumerations.LocationProviderType;
import cgeo.geocaching.geopoint.Geopoint;
import android.location.Location;
import android.location.LocationManager;
public class GeoData extends Location implements IGeoData {
public static final String INITIAL_PROVIDER = "initial";
public static final String FUSED_PROVIDER = "fused";
public static final String LOW_POWER_PROVIDER = "low-power";
public GeoData(final Location location) {
super(location);
}
@Override
public Location getLocation() {
return this;
}
private static LocationProviderType getLocationProviderType(final String provider) {
if (provider.equals(LocationManager.GPS_PROVIDER)) {
return LocationProviderType.GPS;
}
if (provider.equals(LocationManager.NETWORK_PROVIDER)) {
return LocationProviderType.NETWORK;
}
// LocationManager.FUSED_PROVIDER constant is not available at API level 9
if (provider.equals(FUSED_PROVIDER)) {
return LocationProviderType.FUSED;
}
if (provider.equals(LOW_POWER_PROVIDER)) {
return LocationProviderType.LOW_POWER;
}
return LocationProviderType.LAST;
}
@Override
public LocationProviderType getLocationProvider() {
return getLocationProviderType(getProvider());
}
@Override
public Geopoint getCoords() {
return new Geopoint(this);
}
// Some devices will not have the last position available (for example the emulator). In this case,
// rather than waiting forever for a position update which might never come, we emulate it by placing
// the user arbitrarly at Paris Notre-Dame, one of the most visited free tourist attractions in the world.
public static GeoData dummyLocation() {
final Location location = new Location(INITIAL_PROVIDER);
location.setLatitude(48.85308);
location.setLongitude(2.34962);
return new GeoData(location);
}
}
|