[map] guides api is added into guides manager

This commit is contained in:
Arsentiy Milchakov 2020-04-22 17:36:46 +03:00 committed by Daria Volvenkova
parent 00896b05c3
commit 152aba80cb
6 changed files with 65 additions and 13 deletions

View file

@ -75,6 +75,8 @@ set(
gps_tracker.hpp
guides_manager.cpp
guides_manager.hpp
guides_on_map_delegate.cpp
guides_on_map_delegate.hpp
isolines_manager.cpp
isolines_manager.hpp
local_ads_manager.cpp

View file

@ -6,6 +6,7 @@
#include "map/download_on_map_ads_delegate.hpp"
#include "map/everywhere_search_params.hpp"
#include "map/gps_tracker.hpp"
#include "map/guides_on_map_delegate.hpp"
#include "map/notifications/notification_manager_delegate.hpp"
#include "map/notifications/notification_queue.hpp"
#include "map/promo_catalog_poi_checker.hpp"
@ -549,6 +550,8 @@ Framework::Framework(FrameworkParams const & params)
*m_cityFinder, catalogHeadersProvider));
eye::Eye::Instance().Subscribe(m_promoApi.get());
m_guidesManager.SetApiDelegate(make_unique<GuidesOnMapDelegate>(catalogHeadersProvider));
// Clean the no longer used key from old devices.
// Remove this line after April 2020 (assuming the majority of devices
// will have updated by then).

View file

@ -60,3 +60,8 @@ void GuidesManager::SetGalleryListener(GuidesGalleryChangedFn const & onGalleryC
{
m_onGalleryChangedFn = onGalleryChangedFn;
}
void GuidesManager::SetApiDelegate(std::unique_ptr<GuidesOnMapDelegate> apiDelegate)
{
m_api.SetDelegate(std::move(apiDelegate));
}

View file

@ -1,14 +1,19 @@
#pragma once
#include "map/catalog_headers_provider.hpp"
#include "map/guides_on_map_delegate.hpp"
#include "partners_api/guides_on_map_api.hpp"
#include "geometry/rect2d.hpp"
#include "geometry/screenbase.hpp"
#include <boost/optional.hpp>
#include <functional>
#include <memory>
#include <string>
#include <vector>
#include <boost/optional.hpp>
class GuidesManager final
{
public:
@ -20,17 +25,6 @@ public:
NetworkError
};
GuidesState GetState() const;
using GuidesStateChangedFn = std::function<void(GuidesState state)>;
void SetStateListener(GuidesStateChangedFn const & onStateChangedFn);
void UpdateViewport(ScreenBase const & screen);
void Invalidate();
void SetEnabled(bool enabled);
bool IsEnabled() const;
struct GuidesGallery
{
struct Item
@ -71,6 +65,17 @@ public:
std::vector<Item> m_items;
};
GuidesState GetState() const;
using GuidesStateChangedFn = std::function<void(GuidesState state)>;
void SetStateListener(GuidesStateChangedFn const & onStateChangedFn);
void UpdateViewport(ScreenBase const & screen);
void Invalidate();
void SetEnabled(bool enabled);
bool IsEnabled() const;
GuidesGallery GetGallery() const;
std::string GetActiveGuide() const;
void SetActiveGuide(std::string const & guideId);
@ -78,12 +83,16 @@ public:
using GuidesGalleryChangedFn = std::function<void(bool reloadGallery)>;
void SetGalleryListener(GuidesGalleryChangedFn const & onGalleryChangedFn);
void SetApiDelegate(std::unique_ptr<GuidesOnMapDelegate> apiDelegate);
private:
void ChangeState(GuidesState newState);
GuidesState m_state = GuidesState::Disabled;
GuidesStateChangedFn m_onStateChangedFn;
GuidesGalleryChangedFn m_onGalleryChangedFn;
guides_on_map::Api m_api;
};
std::string DebugPrint(GuidesManager::GuidesState state);

View file

@ -0,0 +1,15 @@
#include "map/guides_on_map_delegate.hpp"
GuidesOnMapDelegate::GuidesOnMapDelegate(
std::shared_ptr<CatalogHeadersProvider> const & headersProvider)
: m_headersProvider(headersProvider)
{
}
platform::HttpClient::Headers GuidesOnMapDelegate::GetHeaders()
{
if (!m_headersProvider)
return {};
return m_headersProvider->GetHeaders();
}

View file

@ -0,0 +1,18 @@
#pragma once
#include "map/catalog_headers_provider.hpp"
#include "partners_api/guides_on_map_api.hpp"
#include <memory>
class GuidesOnMapDelegate : public guides_on_map::Api::Delegate
{
public:
GuidesOnMapDelegate(std::shared_ptr<CatalogHeadersProvider> const & headersProvider);
platform::HttpClient::Headers GetHeaders() override;
private:
std::shared_ptr<CatalogHeadersProvider> m_headersProvider;
};