forked from organicmaps/organicmaps
Review fix.
This commit is contained in:
parent
3aaed3bd32
commit
16b5af3b02
2 changed files with 14 additions and 15 deletions
|
@ -16,7 +16,6 @@
|
|||
namespace
|
||||
{
|
||||
auto constexpr kRequestAttemptsCount = 3;
|
||||
double const kMinRequestIntervalTimeSec = 2.0;
|
||||
} // namespace
|
||||
|
||||
GuidesManager::GuidesState GuidesManager::GetState() const
|
||||
|
@ -33,11 +32,8 @@ void GuidesManager::UpdateViewport(ScreenBase const & screen)
|
|||
{
|
||||
auto const zoom = df::GetDrawTileScale(screen);
|
||||
|
||||
if (m_requestTimer.ElapsedSeconds() < kMinRequestIntervalTimeSec)
|
||||
return;
|
||||
|
||||
// TODO(a): to implement correct way to filter out same rects.
|
||||
if (m_currentRect.EqualDxDy(screen.GlobalRect(), 1e-5) && m_zoom == zoom)
|
||||
if (m_currentRect.EqualDxDy(screen.GlobalRect(), 1e-4) && m_zoom == zoom)
|
||||
return;
|
||||
|
||||
m_currentRect = screen.GlobalRect();
|
||||
|
@ -71,6 +67,10 @@ void GuidesManager::SetEnabled(bool enabled)
|
|||
|
||||
Clear();
|
||||
ChangeState(newState);
|
||||
|
||||
if (!enabled)
|
||||
return;
|
||||
|
||||
RequestGuides(m_currentRect, m_zoom);
|
||||
}
|
||||
|
||||
|
@ -90,7 +90,9 @@ void GuidesManager::ChangeState(GuidesState newState)
|
|||
|
||||
void GuidesManager::RequestGuides(m2::AnyRectD const & rect, int zoom)
|
||||
{
|
||||
m_requestTimer.Reset();
|
||||
if (rect.GetLocalRect().IsEmptyInterior())
|
||||
return;
|
||||
|
||||
auto const requestNumber = ++m_requestCounter;
|
||||
m_api.GetGuidesOnMap(
|
||||
rect, zoom,
|
||||
|
@ -109,7 +111,7 @@ void GuidesManager::RequestGuides(m2::AnyRectD const & rect, int zoom)
|
|||
UpdateGuidesMarks();
|
||||
|
||||
if (m_onGalleryChanged)
|
||||
m_onGalleryChanged(true);
|
||||
m_onGalleryChanged(true /* reload */);
|
||||
},
|
||||
[this, requestNumber, zoom]() mutable {
|
||||
if (m_state == GuidesState::Disabled || m_state == GuidesState::FatalNetworkError)
|
||||
|
@ -246,7 +248,7 @@ void GuidesManager::SetActiveGuide(std::string const & guideId)
|
|||
return;
|
||||
|
||||
m_activeGuide = guideId;
|
||||
UpdateGuideSelection();
|
||||
UpdateActiveGuide();
|
||||
}
|
||||
|
||||
void GuidesManager::SetGalleryListener(GuidesGalleryChangedFn const & onGalleryChanged)
|
||||
|
@ -297,7 +299,7 @@ void GuidesManager::UpdateGuidesMarks()
|
|||
mark->SetIndex(++m_nextMarkIndex);
|
||||
}
|
||||
}
|
||||
UpdateGuideSelection();
|
||||
UpdateActiveGuide();
|
||||
}
|
||||
|
||||
void GuidesManager::OnClusterSelected(GuidesClusterMark const & mark, ScreenBase const & screen)
|
||||
|
@ -314,10 +316,10 @@ void GuidesManager::OnGuideSelected(GuideMark const & mark)
|
|||
|
||||
m_activeGuide = mark.GetGuideId();
|
||||
if (m_onGalleryChanged)
|
||||
m_onGalleryChanged(false);
|
||||
m_onGalleryChanged(false /* reload */);
|
||||
}
|
||||
|
||||
void GuidesManager::UpdateGuideSelection()
|
||||
void GuidesManager::UpdateActiveGuide()
|
||||
{
|
||||
auto es = m_bmManager->GetEditSession();
|
||||
es.ClearGroup(UserMark::Type::GUIDE_SELECTION);
|
||||
|
|
|
@ -12,8 +12,6 @@
|
|||
#include "geometry/rect2d.hpp"
|
||||
#include "geometry/screenbase.hpp"
|
||||
|
||||
#include "base/timer.hpp"
|
||||
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
@ -100,7 +98,6 @@ public:
|
|||
|
||||
void SetApiDelegate(std::unique_ptr<guides_on_map::Api::Delegate> apiDelegate);
|
||||
|
||||
void UpdateGuideSelection();
|
||||
void OnClusterSelected(GuidesClusterMark const & mark, ScreenBase const & screen);
|
||||
void OnGuideSelected(GuideMark const & mark);
|
||||
|
||||
|
@ -111,6 +108,7 @@ private:
|
|||
|
||||
bool IsGuideDownloaded(std::string const & guideId) const;
|
||||
void UpdateGuidesMarks();
|
||||
void UpdateActiveGuide();
|
||||
|
||||
GuidesState m_state = GuidesState::Disabled;
|
||||
GuidesStateChangedFn m_onStateChanged;
|
||||
|
@ -119,7 +117,6 @@ private:
|
|||
int m_zoom = 0;
|
||||
m2::AnyRectD m_currentRect;
|
||||
|
||||
base::Timer m_requestTimer;
|
||||
uint64_t m_requestCounter = 0;
|
||||
uint8_t m_errorRequestsCount = 0;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue