From 202e948d577aad49436fc1111c51354f4bc0e383 Mon Sep 17 00:00:00 2001 From: Ilya Grechuhin Date: Thu, 22 Jun 2017 16:02:44 +0300 Subject: [PATCH] [MAPSME-4671] Review fixes. --- iphone/Maps/UI/PlacePage/MWMPlacePageData.h | 24 ++--- iphone/Maps/UI/PlacePage/MWMPlacePageData.mm | 88 +++++++++---------- .../Maps/UI/PlacePage/MWMPlacePageManager.mm | 3 +- 3 files changed, 57 insertions(+), 58 deletions(-) diff --git a/iphone/Maps/UI/PlacePage/MWMPlacePageData.h b/iphone/Maps/UI/PlacePage/MWMPlacePageData.h index 2d92a0150b..fa3212af7b 100644 --- a/iphone/Maps/UI/PlacePage/MWMPlacePageData.h +++ b/iphone/Maps/UI/PlacePage/MWMPlacePageData.h @@ -146,8 +146,8 @@ using BannerIsReady = void (^)(); - (NSString *)sponsoredId; - (void)assignOnlinePriceToLabel:(UILabel *)label; - (NSString *)hotelDescription; -- (vector const &)facilities; -- (vector const &)reviews; +- (std::vector const &)facilities; +- (std::vector const &)reviews; - (NSUInteger)numberOfReviews; - (NSURL *)URLToAllReviews; - (NSArray *)photos; @@ -178,16 +178,16 @@ using BannerIsReady = void (^)(); - (void)logLocalAdsEvent:(local_ads::EventType)type; // Table view's data -- (vector const &)sections; -- (vector const &)previewRows; -- (vector const &)photosRows; -- (vector const &)descriptionRows; -- (vector const &)hotelFacilitiesRows; -- (vector const &)hotelReviewsRows; -- (vector const &)viatorRows; -- (vector const &)metainfoRows; -- (vector const &)adRows; -- (vector const &)buttonsRows; +- (std::vector const &)sections; +- (std::vector const &)previewRows; +- (std::vector const &)photosRows; +- (std::vector const &)descriptionRows; +- (std::vector const &)hotelFacilitiesRows; +- (std::vector const &)hotelReviewsRows; +- (std::vector const &)viatorRows; +- (std::vector const &)metainfoRows; +- (std::vector const &)adRows; +- (std::vector const &)buttonsRows; // Table view metainfo rows - (NSString *)stringForRow:(place_page::MetainfoRows)row; diff --git a/iphone/Maps/UI/PlacePage/MWMPlacePageData.mm b/iphone/Maps/UI/PlacePage/MWMPlacePageData.mm index 6c7ac9137c..0fca5ce22f 100644 --- a/iphone/Maps/UI/PlacePage/MWMPlacePageData.mm +++ b/iphone/Maps/UI/PlacePage/MWMPlacePageData.mm @@ -39,16 +39,16 @@ using namespace place_page; { Info m_info; - vector m_sections; - vector m_previewRows; - vector m_viatorRows; - vector m_metainfoRows; - vector m_adRows; - vector m_buttonsRows; - vector m_hotelPhotosRows; - vector m_hotelDescriptionRows; - vector m_hotelFacilitiesRows; - vector m_hotelReviewsRows; + std::vector m_sections; + std::vector m_previewRows; + std::vector m_viatorRows; + std::vector m_metainfoRows; + std::vector m_adRows; + std::vector m_buttonsRows; + std::vector m_hotelPhotosRows; + std::vector m_hotelDescriptionRows; + std::vector m_hotelFacilitiesRows; + std::vector m_hotelReviewsRows; booking::HotelInfo m_hotelInfo; std::vector m_viatorProducts; @@ -216,24 +216,24 @@ using namespace place_page; std::string const currency = self.currencyFormatter.currencyCode.UTF8String; std::string const viatorId = [self sponsoredId].UTF8String; - api->GetTop5Products( - viatorId, currency, [viatorId, self](std::string const & destId, - std::vector const & products) { - if (viatorId != destId) - return; - dispatch_async(dispatch_get_main_queue(), [products, self] { - m_viatorProducts = products; + api->GetTop5Products(viatorId, currency, + [viatorId, self](std::string const & destId, std::vector const & products) + { + if (viatorId != destId) + return; + dispatch_async(dispatch_get_main_queue(), [products, self] { + m_viatorProducts = products; - auto & sections = self->m_sections; - auto const begin = sections.begin(); - auto const end = sections.end(); + auto & sections = self->m_sections; + auto const begin = sections.begin(); + auto const end = sections.end(); - sections.insert(find(begin, end, Sections::Preview) + 1, Sections::Viator); - m_viatorRows.emplace_back(ViatorRow::Regular); + sections.insert(find(begin, end, Sections::Preview) + 1, Sections::Viator); + m_viatorRows.emplace_back(ViatorRow::Regular); - self.sectionsAreReadyCallback({1, 1}, self); - }); + self.sectionsAreReadyCallback({1, 1}, self); }); + }); }); } @@ -251,7 +251,7 @@ using namespace place_page; if (!api) return; - string const hotelId = self.sponsoredId.UTF8String; + std::string const hotelId = self.sponsoredId.UTF8String; api->GetHotelInfo(hotelId, [[AppInfo sharedInfo] twoLetterLanguageId].UTF8String, [hotelId, self](booking::HotelInfo const & hotelInfo) { @@ -362,8 +362,9 @@ using namespace place_page; - (void)dealloc { - if (self.nativeAd) - [[MWMBannersCache cache] bannerIsOutOfScreenWithCoreBanner:self.nativeAd]; + auto nativeAd = self.nativeAd; + if (nativeAd) + [[MWMBannersCache cache] bannerIsOutOfScreenWithCoreBanner:nativeAd]; } #pragma mark - Getters @@ -442,10 +443,10 @@ using namespace place_page; if (Platform::ConnectionStatus() == Platform::EConnectionType::CONNECTION_NONE) return; - string const currency = self.currencyFormatter.currencyCode.UTF8String; + std::string const currency = self.currencyFormatter.currencyCode.UTF8String; - auto const func = [self, label, currency](string const & hotelId, string const & minPrice, - string const & priceCurrency) { + auto const func = [self, label, currency](std::string const & hotelId, std::string const & minPrice, + std::string const & priceCurrency) { if (currency != priceCurrency) return; @@ -492,8 +493,8 @@ using namespace place_page; } - (NSString *)hotelDescription { return @(m_hotelInfo.m_description.c_str()); } -- (vector const &)facilities { return m_hotelInfo.m_facilities; } -- (vector const &)reviews { return m_hotelInfo.m_reviews; } +- (std::vector const &)facilities { return m_hotelInfo.m_facilities; } +- (std::vector const &)reviews { return m_hotelInfo.m_reviews; } - (NSUInteger)numberOfReviews { return m_hotelInfo.m_scoreCount; } - (NSURL *)URLToAllReviews { return [NSURL URLWithString:@(m_info.GetSponsoredReviewUrl().c_str())]; } - (NSArray *)photos @@ -598,22 +599,21 @@ using namespace place_page; - (int8_t)intermediateIndex { return m_info.m_intermediateIndex; } - (NSString *)address { return @(m_info.GetAddress().c_str()); } - (NSString *)apiURL { return @(m_info.GetApiUrl().c_str()); } -- (vector const &)sections { return m_sections; } -- (vector const &)previewRows { return m_previewRows; } -- (vector const &)viatorRows { return m_viatorRows; } -- (vector const &)metainfoRows { return m_metainfoRows; } -- (vector &)mutableMetainfoRows { return m_metainfoRows; } -- (vector const &)adRows { return m_adRows; } -- (vector const &)buttonsRows { return m_buttonsRows; } -- (vector const &)photosRows { return m_hotelPhotosRows; } -- (vector const &)descriptionRows { return m_hotelDescriptionRows; } -- (vector const &)hotelFacilitiesRows { return m_hotelFacilitiesRows; } -- (vector const &)hotelReviewsRows { return m_hotelReviewsRows; } +- (std::vector const &)sections { return m_sections; } +- (std::vector const &)previewRows { return m_previewRows; } +- (std::vector const &)viatorRows { return m_viatorRows; } +- (std::vector const &)metainfoRows { return m_metainfoRows; } +- (std::vector &)mutableMetainfoRows { return m_metainfoRows; } +- (std::vector const &)adRows { return m_adRows; } +- (std::vector const &)buttonsRows { return m_buttonsRows; } +- (std::vector const &)photosRows { return m_hotelPhotosRows; } +- (std::vector const &)descriptionRows { return m_hotelDescriptionRows; } +- (std::vector const &)hotelFacilitiesRows { return m_hotelFacilitiesRows; } +- (std::vector const &)hotelReviewsRows { return m_hotelReviewsRows; } - (NSString *)stringForRow:(MetainfoRows)row { switch (row) { - case MetainfoRows::ExtendedOpeningHours: return nil; case MetainfoRows::OpeningHours: return @(m_info.GetOpeningHours().c_str()); case MetainfoRows::Phone: return @(m_info.GetPhone().c_str()); diff --git a/iphone/Maps/UI/PlacePage/MWMPlacePageManager.mm b/iphone/Maps/UI/PlacePage/MWMPlacePageManager.mm index 55bacffd73..dde32e0b6d 100644 --- a/iphone/Maps/UI/PlacePage/MWMPlacePageManager.mm +++ b/iphone/Maps/UI/PlacePage/MWMPlacePageManager.mm @@ -518,8 +518,7 @@ void logSponsoredEvent(MWMPlacePageData * data, NSString * eventName) - (void)openViatorURL:(nullable NSURL *)url { - auto u = url ? url : self.data.sponsoredURL; - if (u) + if (auto u = url ?: self.data.sponsoredURL) [self.ownerViewController openUrl:u]; }