forked from organicmaps/organicmaps
Fixed an issue when swiping through many regions they were all added to the download queue
This commit is contained in:
parent
1e3acb49ea
commit
38331ad944
2 changed files with 17 additions and 4 deletions
|
@ -288,6 +288,7 @@ Framework::Framework()
|
|||
, m_bmManager(*this)
|
||||
, m_fixedSearchResults(0)
|
||||
, m_lastReportedCountry(kInvalidCountryId)
|
||||
, m_watchdogCountryUpdate(seconds(2))
|
||||
{
|
||||
// Restore map style before classificator loading
|
||||
int mapStyle = MapStyleLight;
|
||||
|
@ -942,11 +943,19 @@ void Framework::ClearAllCaches()
|
|||
m_searchEngine->ClearCaches();
|
||||
}
|
||||
|
||||
void Framework::OnCheckUpdateCurrentCountry(m2::PointF const & pt, int zoomLevel)
|
||||
{
|
||||
if (zoomLevel <= scales::GetUpperWorldScale())
|
||||
m_watchdogCountryUpdate.Drop();
|
||||
else
|
||||
m_watchdogCountryUpdate.RestartWith([this, pt, zoomLevel]{
|
||||
OnUpdateCurrentCountry(pt, zoomLevel);
|
||||
});
|
||||
}
|
||||
|
||||
void Framework::OnUpdateCurrentCountry(m2::PointF const & pt, int zoomLevel)
|
||||
{
|
||||
storage::TCountryId newCountryId;
|
||||
if (zoomLevel > scales::GetUpperWorldScale())
|
||||
newCountryId = m_storage.FindCountryIdByFile(m_infoGetter->GetRegionCountryId(m2::PointD(pt)));
|
||||
storage::TCountryId newCountryId = m_infoGetter->GetRegionCountryId(m2::PointD(pt));
|
||||
|
||||
if (newCountryId == m_lastReportedCountry)
|
||||
return;
|
||||
|
@ -1356,7 +1365,7 @@ void Framework::CreateDrapeEngine(ref_ptr<dp::OGLContextFactory> contextFactory,
|
|||
|
||||
auto isCountryLoadedFn = bind(&Framework::IsCountryLoaded, this, _1);
|
||||
auto isCountryLoadedByNameFn = bind(&Framework::IsCountryLoadedByName, this, _1);
|
||||
auto updateCurrentCountryFn = bind(&Framework::OnUpdateCurrentCountry, this, _1, _2);
|
||||
auto updateCurrentCountryFn = bind(&Framework::OnCheckUpdateCurrentCountry, this, _1, _2);
|
||||
|
||||
bool allow3d;
|
||||
bool allow3dBuildings;
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
#include "geometry/rect2d.hpp"
|
||||
#include "geometry/screenbase.hpp"
|
||||
|
||||
#include "base/deferred_task.hpp"
|
||||
#include "base/macros.hpp"
|
||||
#include "base/strings_bundle.hpp"
|
||||
#include "base/thread_checker.hpp"
|
||||
|
@ -41,6 +42,7 @@
|
|||
#include "std/list.hpp"
|
||||
#include "std/shared_ptr.hpp"
|
||||
#include "std/target_os.hpp"
|
||||
#include "std/thread.hpp"
|
||||
#include "std/unique_ptr.hpp"
|
||||
#include "std/vector.hpp"
|
||||
#include "std/weak_ptr.hpp"
|
||||
|
@ -126,6 +128,7 @@ protected:
|
|||
double m_startForegroundTime;
|
||||
|
||||
storage::Storage m_storage;
|
||||
DeferredTask m_watchdogCountryUpdate;
|
||||
|
||||
location::TMyPositionModeChanged m_myPositionListener;
|
||||
|
||||
|
@ -357,6 +360,7 @@ private:
|
|||
|
||||
void FillSearchResultsMarks(search::Results const & results);
|
||||
|
||||
void OnCheckUpdateCurrentCountry(m2::PointF const & pt, int zoomLevel);
|
||||
void OnUpdateCurrentCountry(m2::PointF const & pt, int zoomLevel);
|
||||
|
||||
storage::TCountryId m_lastReportedCountry;
|
||||
|
|
Loading…
Add table
Reference in a new issue