forked from organicmaps/organicmaps
[map] [framework] implement track info updates observing to the framework
The updates can be retrieved using the `SetTrackRecordingInfoUpdateHandler` Signed-off-by: Kiryl Kaveryn <kirylkaveryn@gmail.com>
This commit is contained in:
parent
de0650f3b2
commit
a2eaccc564
5 changed files with 28 additions and 9 deletions
|
@ -1587,7 +1587,7 @@ void Framework::CreateDrapeEngine(ref_ptr<dp::GraphicsContextFactory> contextFac
|
|||
LoadViewport();
|
||||
|
||||
if (m_connectToGpsTrack)
|
||||
GpsTracker::Instance().Connect(bind(&Framework::OnUpdateGpsTrackPointsCallback, this, _1, _2));
|
||||
GpsTracker::Instance().Connect(bind(&Framework::OnUpdateGpsTrackPointsCallback, this, _1, _2, _3));
|
||||
|
||||
GetBookmarkManager().SetDrapeEngine(make_ref(m_drapeEngine));
|
||||
m_drapeApi.SetDrapeEngine(make_ref(m_drapeEngine));
|
||||
|
@ -1699,7 +1699,7 @@ void Framework::ConnectToGpsTracker()
|
|||
if (m_drapeEngine)
|
||||
{
|
||||
m_drapeEngine->ClearGpsTrackPoints();
|
||||
GpsTracker::Instance().Connect(bind(&Framework::OnUpdateGpsTrackPointsCallback, this, _1, _2));
|
||||
GpsTracker::Instance().Connect(bind(&Framework::OnUpdateGpsTrackPointsCallback, this, _1, _2, _3));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1720,10 +1720,17 @@ void Framework::StartTrackRecording()
|
|||
if (m_drapeEngine)
|
||||
{
|
||||
m_drapeEngine->ClearGpsTrackPoints();
|
||||
tracker.Connect(bind(&Framework::OnUpdateGpsTrackPointsCallback, this, _1, _2));
|
||||
tracker.Connect(bind(&Framework::OnUpdateGpsTrackPointsCallback, this, _1, _2, _3));
|
||||
}
|
||||
}
|
||||
|
||||
void Framework::SetTrackRecordingUpdateHandler(TrackRecordingUpdateHandler && trackRecordingDidUpdate)
|
||||
{
|
||||
m_trackRecordingUpdateHandler = std::move(trackRecordingDidUpdate);
|
||||
if (m_trackRecordingUpdateHandler)
|
||||
m_trackRecordingUpdateHandler(std::move(GpsTracker::Instance().GetTrackInfo()));
|
||||
}
|
||||
|
||||
void Framework::StopTrackRecording()
|
||||
{
|
||||
m_connectToGpsTrack = false;
|
||||
|
@ -1752,7 +1759,8 @@ bool Framework::IsTrackRecordingEnabled() const
|
|||
}
|
||||
|
||||
void Framework::OnUpdateGpsTrackPointsCallback(vector<pair<size_t, location::GpsInfo>> && toAdd,
|
||||
pair<size_t, size_t> const & toRemove)
|
||||
pair<size_t, size_t> const & toRemove,
|
||||
GpsTrackInfo const & trackInfo)
|
||||
{
|
||||
ASSERT(m_drapeEngine.get() != nullptr, ());
|
||||
|
||||
|
@ -1779,6 +1787,9 @@ void Framework::OnUpdateGpsTrackPointsCallback(vector<pair<size_t, location::Gps
|
|||
}
|
||||
|
||||
m_drapeEngine->UpdateGpsTrackPoints(std::move(pointsAdd), std::move(indicesRemove));
|
||||
|
||||
if (m_trackRecordingUpdateHandler)
|
||||
m_trackRecordingUpdateHandler(std::move(trackInfo));
|
||||
}
|
||||
|
||||
void Framework::MarkMapStyle(MapStyle mapStyle)
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#include "map/track.hpp"
|
||||
#include "map/traffic_manager.hpp"
|
||||
#include "map/transit/transit_reader.hpp"
|
||||
#include "map/gps_track_collection.hpp"
|
||||
|
||||
#include "drape_frontend/gui/skin.hpp"
|
||||
#include "drape_frontend/drape_api.hpp"
|
||||
|
@ -435,7 +436,9 @@ public:
|
|||
void ConnectToGpsTracker();
|
||||
void DisconnectFromGpsTracker();
|
||||
|
||||
using TrackRecordingUpdateHandler = platform::SafeCallback<void(GpsTrackInfo const & trackInfo)>;
|
||||
void StartTrackRecording();
|
||||
void SetTrackRecordingUpdateHandler(TrackRecordingUpdateHandler && trackRecordingDidUpdate);
|
||||
void StopTrackRecording();
|
||||
void SaveTrackRecordingWithName(std::string const & name);
|
||||
bool IsTrackRecordingEmpty() const;
|
||||
|
@ -463,7 +466,10 @@ private:
|
|||
TCurrentCountryChanged m_currentCountryChanged;
|
||||
|
||||
void OnUpdateGpsTrackPointsCallback(std::vector<std::pair<size_t, location::GpsInfo>> && toAdd,
|
||||
std::pair<size_t, size_t> const & toRemove);
|
||||
std::pair<size_t, size_t> const & toRemove,
|
||||
GpsTrackInfo const & trackInfo);
|
||||
|
||||
TrackRecordingUpdateHandler m_trackRecordingUpdateHandler;
|
||||
|
||||
CachingRankTableLoader m_popularityLoader;
|
||||
|
||||
|
|
|
@ -303,7 +303,7 @@ void GpsTrack::NotifyCallback(pair<size_t, size_t> const & addedIds, pair<size_t
|
|||
if (toAdd.empty())
|
||||
return; // nothing to send
|
||||
|
||||
m_callback(std::move(toAdd), make_pair(kInvalidId, kInvalidId));
|
||||
m_callback(std::move(toAdd), make_pair(kInvalidId, kInvalidId), std::move(m_collection->GetTrackInfo()));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -324,6 +324,6 @@ void GpsTrack::NotifyCallback(pair<size_t, size_t> const & addedIds, pair<size_t
|
|||
if (toAdd.empty() && evictedIds.first == kInvalidId)
|
||||
return; // nothing to send
|
||||
|
||||
m_callback(std::move(toAdd), evictedIds);
|
||||
m_callback(std::move(toAdd), evictedIds, std::move(m_collection->GetTrackInfo()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,7 +46,8 @@ public:
|
|||
/// @note Calling of a GpsTrack.SetCallback function from the callback causes deadlock.
|
||||
using TGpsTrackDiffCallback =
|
||||
std::function<void(std::vector<std::pair<size_t, location::GpsInfo>> && toAdd,
|
||||
std::pair<size_t, size_t> const & toRemove)>;
|
||||
std::pair<size_t, size_t> const & toRemove,
|
||||
GpsTrackInfo const & trackInfo)>;
|
||||
|
||||
/// Sets callback on change of gps track.
|
||||
/// @param callback - callback callable object
|
||||
|
|
|
@ -21,7 +21,8 @@ public:
|
|||
|
||||
using TGpsTrackDiffCallback =
|
||||
std::function<void(std::vector<std::pair<size_t, location::GpsInfo>> && toAdd,
|
||||
std::pair<size_t, size_t> const & toRemove)>;
|
||||
std::pair<size_t, size_t> const & toRemove,
|
||||
GpsTrackInfo const & trackInfo)>;
|
||||
|
||||
void Connect(TGpsTrackDiffCallback const & fn);
|
||||
void Disconnect();
|
||||
|
|
Loading…
Add table
Reference in a new issue