[ios] Fixed extra section duplication. (#4573)

[ios] Fixed extra section duplication.
This commit is contained in:
Илья Гречухин 2016-10-27 17:44:19 +03:00 committed by Sergey Yershov
parent b52a46094e
commit 94c92f8708
2 changed files with 15 additions and 1 deletions

View file

@ -39,6 +39,7 @@ auto constexpr extraSection = MWMMapDownloaderDataSourceExtraSection::NearMe;
- (void)configNearMeSection
{
[self removeExtraSection:extraSection];
CLLocation * lastLocation = [MWMLocationManager lastLocation];
if (!lastLocation)
return;
@ -55,7 +56,18 @@ auto constexpr extraSection = MWMMapDownloaderDataSourceExtraSection::NearMe;
- (void)addExtraSection:(MWMMapDownloaderDataSourceExtraSection)extraSection
{
m_extraSections.push_back(extraSection);
auto const endIt = m_extraSections.end();
auto const findIt = find(m_extraSections.begin(), endIt, extraSection);
if (findIt == endIt)
{
m_extraSections.emplace_back(extraSection);
sort(m_extraSections.begin(), m_extraSections.end());
}
}
- (void)removeExtraSection:(MWMMapDownloaderDataSourceExtraSection)extraSection
{
m_extraSections.erase(remove(m_extraSections.begin(), m_extraSections.end(), extraSection), m_extraSections.end());
}
- (BOOL)isExtraSection:(MWMMapDownloaderDataSourceExtraSection)extraSection

View file

@ -17,6 +17,7 @@ auto constexpr extraSection = MWMMapDownloaderDataSourceExtraSection::Ads;
- (void)load;
- (void)addExtraSection:(MWMMapDownloaderDataSourceExtraSection)extraSection;
- (void)removeExtraSection:(MWMMapDownloaderDataSourceExtraSection)extraSection;
- (BOOL)isExtraSection:(MWMMapDownloaderDataSourceExtraSection)extraSection
atIndex:(NSInteger)sectionIndex;
@ -33,6 +34,7 @@ auto constexpr extraSection = MWMMapDownloaderDataSourceExtraSection::Ads;
- (void)configAdsSection
{
[self removeExtraSection:extraSection];
if ([UIColor isNightMode] || !GetFramework().GetStorage().HaveDownloadedCountries())
return;
if ([MWMMyTarget manager].bannersCount != 0)