Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/map
diff options
context:
space:
mode:
authorArsentiy Milchakov <milcars@mapswithme.com>2018-08-30 17:42:46 +0300
committerRoman Kuznetsov <r.kuznetsow@gmail.com>2018-08-30 17:47:03 +0300
commitb6aa269e3ce9eae249a0881c22e43750d1156fba (patch)
tree7abe2f2144cb99896680b0c65d0229e017c692f8 /map
parentae25bf71ca921f6860aa836635e5ef7bbf3013f9 (diff)
[tips] set delegate fix
Diffstat (limited to 'map')
-rw-r--r--map/framework.cpp1
-rw-r--r--map/tips_api.cpp16
-rw-r--r--map/tips_api.hpp5
3 files changed, 9 insertions, 13 deletions
diff --git a/map/framework.cpp b/map/framework.cpp
index 44b35bd789..64c5dc8a74 100644
--- a/map/framework.cpp
+++ b/map/framework.cpp
@@ -389,6 +389,7 @@ Framework::Framework(FrameworkParams const & params)
, m_lastReportedCountry(kInvalidCountryId)
, m_popularityLoader(m_model.GetDataSource())
, m_subscription(std::make_unique<Subscription>())
+ , m_tipsApi(static_cast<TipsApi::Delegate &>(*this))
{
m_startBackgroundTime = my::Timer::LocalTime();
diff --git a/map/tips_api.cpp b/map/tips_api.cpp
index dadd2a6665..09ce43cf20 100644
--- a/map/tips_api.cpp
+++ b/map/tips_api.cpp
@@ -104,7 +104,8 @@ size_t TipsApi::GetGotitClicksCountToDisable()
return kGotitClicksCountToDisable;
}
-TipsApi::TipsApi()
+TipsApi::TipsApi(Delegate const & delegate)
+ : m_delegate(delegate)
{
m_conditions =
{{
@@ -115,29 +116,24 @@ TipsApi::TipsApi()
// Condition for Tips::Type::DiscoverButton type.
[this]
{
- auto const pos = m_delegate->GetCurrentPosition();
+ auto const pos = m_delegate.GetCurrentPosition();
if (!pos.is_initialized())
return false;
- return m_delegate->IsCountryLoaded(pos.get());
+ return m_delegate.IsCountryLoaded(pos.get());
},
// Condition for Tips::Type::MapsLayers type.
[this]
{
- auto const pos = m_delegate->GetCurrentPosition();
+ auto const pos = m_delegate.GetCurrentPosition();
if (!pos.is_initialized())
return false;
- return m_delegate->HaveTransit(pos.get());
+ return m_delegate.HaveTransit(pos.get());
}
}};
}
-void TipsApi::SetDelegate(std::unique_ptr<Delegate> delegate)
-{
- m_delegate = std::move(delegate);
-}
-
boost::optional<eye::Tip::Type> TipsApi::GetTip() const
{
return GetTipImpl(GetShowAnyTipPeriod(), GetShowSameTipPeriod(), m_conditions);
diff --git a/map/tips_api.hpp b/map/tips_api.hpp
index e974be12d3..0eaec73eea 100644
--- a/map/tips_api.hpp
+++ b/map/tips_api.hpp
@@ -34,9 +34,8 @@ public:
static size_t GetActionClicksCountToDisable();
static size_t GetGotitClicksCountToDisable();
- TipsApi();
+ explicit TipsApi(Delegate const & delegate);
- void SetDelegate(std::unique_ptr<Delegate> delegate);
boost::optional<eye::Tip::Type> GetTip() const;
static boost::optional<eye::Tip::Type> GetTipForTesting(Duration showAnyTipPeriod,
@@ -44,6 +43,6 @@ public:
Conditions const & triggers);
private:
- std::unique_ptr<Delegate> m_delegate;
+ Delegate const & m_delegate;
Conditions m_conditions;
};