diff options
author | rachytski <siarhei.rachytski@gmail.com> | 2012-10-12 20:17:41 +0400 |
---|---|---|
committer | Alex Zolotarev <alex@maps.me> | 2015-09-23 01:45:23 +0300 |
commit | ca29b9e478b433d1a5d1a7a4385410467e97785f (patch) | |
tree | 495139e98cfe42412cff7397884061416b9ac957 /platform | |
parent | f81ed7bd00ca324c400288d0a2df86151d9989cc (diff) |
refactored Location and Compass observers mechanism.
Diffstat (limited to 'platform')
-rw-r--r-- | platform/apple_location_service.mm | 6 | ||||
-rw-r--r-- | platform/location.hpp | 8 | ||||
-rw-r--r-- | platform/location_service.cpp | 13 | ||||
-rw-r--r-- | platform/location_service.hpp | 4 | ||||
-rw-r--r-- | platform/wifi_location_service.cpp | 2 |
5 files changed, 11 insertions, 22 deletions
diff --git a/platform/apple_location_service.mm b/platform/apple_location_service.mm index f8a2d4b459..d8486aaf07 100644 --- a/platform/apple_location_service.mm +++ b/platform/apple_location_service.mm @@ -41,12 +41,12 @@ public: void OnLocationUpdate(GpsInfo const & info) { - m_observer.OnGpsUpdated(info); + m_observer.OnLocationUpdated(info); } void OnDeniedError() { - m_observer.OnLocationStatusChanged(location::EDisabledByUser); + m_observer.OnLocationError(location::EDenied); } virtual void Start() @@ -59,14 +59,12 @@ public: else { [m_locationManager startUpdatingLocation]; - m_observer.OnLocationStatusChanged(location::EStarted); } } virtual void Stop() { [m_locationManager stopUpdatingLocation]; - m_observer.OnLocationStatusChanged(location::EStopped); } }; diff --git a/platform/location.hpp b/platform/location.hpp index af7ce21189..b6df73b4e7 100644 --- a/platform/location.hpp +++ b/platform/location.hpp @@ -9,13 +9,9 @@ namespace location /// after this period we cont position as "too old" static double const POSITION_TIMEOUT_SECONDS = 300.0; - enum TLocationStatus + enum TLocationError { - EStopped = 0, - EStarted, - EFirstEvent, //!< Sent when first valid coorinate is received - ENotSupported, - EDisabledByUser + EDenied }; enum TLocationSource diff --git a/platform/location_service.cpp b/platform/location_service.cpp index 96dee69fb1..1159599b1b 100644 --- a/platform/location_service.cpp +++ b/platform/location_service.cpp @@ -60,20 +60,15 @@ namespace location PositionFilter m_filter; bool m_reportFirstEvent; - virtual void OnLocationStatusChanged(location::TLocationStatus newStatus) + virtual void OnLocationError(location::TLocationError errorCode) { - m_observer.OnLocationStatusChanged(newStatus); + m_observer.OnLocationError(errorCode); } - virtual void OnGpsUpdated(GpsInfo const & info) + virtual void OnLocationUpdated(GpsInfo const & info) { - if (m_reportFirstEvent) - { - m_observer.OnLocationStatusChanged(location::EFirstEvent); - m_reportFirstEvent = false; - } if (m_filter.Passes(info)) - m_observer.OnGpsUpdated(info); + m_observer.OnLocationUpdated(info); } public: diff --git a/platform/location_service.hpp b/platform/location_service.hpp index ae66d3d5d3..a2986b1583 100644 --- a/platform/location_service.hpp +++ b/platform/location_service.hpp @@ -8,8 +8,8 @@ namespace location class LocationObserver { public: - virtual void OnLocationStatusChanged(TLocationStatus newStatus) = 0; - virtual void OnGpsUpdated(GpsInfo const & info) = 0; + virtual void OnLocationError(TLocationError errorCode) = 0; + virtual void OnLocationUpdated(GpsInfo const & info) = 0; }; class LocationService diff --git a/platform/wifi_location_service.cpp b/platform/wifi_location_service.cpp index dfd6beecf9..6954a8aee5 100644 --- a/platform/wifi_location_service.cpp +++ b/platform/wifi_location_service.cpp @@ -48,7 +48,7 @@ namespace location // @TODO introduce flags to mark valid values info.m_timestamp = static_cast<double>(time(NULL)); info.m_source = location::EGoogle; - m_observer.OnGpsUpdated(info); + m_observer.OnLocationUpdated(info); success = true; } } |