diff options
Diffstat (limited to 'main/src/cgeo/geocaching/sensors/GeoData.java')
| -rw-r--r-- | main/src/cgeo/geocaching/sensors/GeoData.java | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/main/src/cgeo/geocaching/sensors/GeoData.java b/main/src/cgeo/geocaching/sensors/GeoData.java new file mode 100644 index 0000000..c0b3974 --- /dev/null +++ b/main/src/cgeo/geocaching/sensors/GeoData.java @@ -0,0 +1,67 @@ +package cgeo.geocaching.sensors; + +import cgeo.geocaching.enumerations.LocationProviderType; +import cgeo.geocaching.geopoint.Geopoint; + +import android.location.Location; +import android.location.LocationManager; + +class GeoData extends Location implements IGeoData { + private final boolean gpsEnabled; + private final int satellitesVisible; + private final int satellitesFixed; + private final boolean pseudoLocation; + + GeoData(final Location location, final boolean gpsEnabled, final int satellitesVisible, final int satellitesFixed, final boolean pseudoLocation) { + super(location); + this.gpsEnabled = gpsEnabled; + this.satellitesVisible = satellitesVisible; + this.satellitesFixed = satellitesFixed; + this.pseudoLocation = pseudoLocation; + } + + @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; + } + return LocationProviderType.LAST; + } + + @Override + public LocationProviderType getLocationProvider() { + return getLocationProviderType(getProvider()); + } + + @Override + public Geopoint getCoords() { + return new Geopoint(this); + } + + @Override + public boolean getGpsEnabled() { + return gpsEnabled; + } + + @Override + public int getSatellitesVisible() { + return satellitesVisible; + } + + @Override + public int getSatellitesFixed() { + return satellitesFixed; + } + + @Override + public boolean isPseudoLocation() { + return pseudoLocation; + } +} |
