From af83a489b9cb98da3aafd494ef492fae62a0972c Mon Sep 17 00:00:00 2001 From: Ilya Grechuhin Date: Mon, 17 Apr 2017 16:45:11 +0300 Subject: [PATCH] [MAPSME-4213] Review fixes. --- iphone/Maps/Core/Search/MWMSearch.h | 4 ++-- iphone/Maps/Core/Search/MWMSearch.mm | 14 +++++++------- iphone/Maps/Core/Search/SearchIndex.swift | 14 ++++++++------ .../TableView/MWMSearchTableViewController.mm | 16 ++++++++-------- 4 files changed, 25 insertions(+), 23 deletions(-) diff --git a/iphone/Maps/Core/Search/MWMSearch.h b/iphone/Maps/Core/Search/MWMSearch.h index 1dbf1a92aa..b3c3947159 100644 --- a/iphone/Maps/Core/Search/MWMSearch.h +++ b/iphone/Maps/Core/Search/MWMSearch.h @@ -15,8 +15,8 @@ + (void)showResult:(search::Result const &)result; -+ (MWMSearchItemType)resultTypeWithIndex:(NSUInteger)index; -+ (NSUInteger)containerIndexWithIndex:(NSUInteger)index; ++ (MWMSearchItemType)resultTypeWithRow:(NSUInteger)row; ++ (NSUInteger)containerIndexWithRow:(NSUInteger)row; + (search::Result const &)resultWithContainerIndex:(NSUInteger)index; + (id)adWithContainerIndex:(NSUInteger)index; diff --git a/iphone/Maps/Core/Search/MWMSearch.mm b/iphone/Maps/Core/Search/MWMSearch.mm index cc8cc6b98b..2dfea20aec 100644 --- a/iphone/Maps/Core/Search/MWMSearch.mm +++ b/iphone/Maps/Core/Search/MWMSearch.mm @@ -227,16 +227,16 @@ using TObservers = NSHashTable<__kindof TObserver>; return [[MWMSearch manager].banners bannerAtIndex:index]; } -+ (MWMSearchItemType)resultTypeWithIndex:(NSUInteger)index ++ (MWMSearchItemType)resultTypeWithRow:(NSUInteger)row { auto itemsIndex = [MWMSearch manager].itemsIndex; - return [itemsIndex resultTypeWithIndex:index]; + return [itemsIndex resultTypeWithRow:row]; } -+ (NSUInteger)containerIndexWithIndex:(NSUInteger)index ++ (NSUInteger)containerIndexWithRow:(NSUInteger)row { auto itemsIndex = [MWMSearch manager].itemsIndex; - return [itemsIndex resultContainerIndexWithIndex:index]; + return [itemsIndex resultContainerIndexWithRow:row]; } + (void)update { [[MWMSearch manager] update]; } @@ -300,9 +300,9 @@ using TObservers = NSHashTable<__kindof TObserver>; - (void)updateItemsIndex { - auto resultsCount = self->m_everywhereResults.GetCount(); - auto itemsIndex = [[MWMSearchIndex alloc] initWithSuggestionsCount:self.suggestionsCount - resultsCount:resultsCount]; + auto const resultsCount = self->m_everywhereResults.GetCount(); + auto const itemsIndex = [[MWMSearchIndex alloc] initWithSuggestionsCount:self.suggestionsCount + resultsCount:resultsCount]; auto bannersCache = [MWMBannersCache cache]; if (resultsCount > 0) { diff --git a/iphone/Maps/Core/Search/SearchIndex.swift b/iphone/Maps/Core/Search/SearchIndex.swift index bfb2adb795..6b6ed59434 100644 --- a/iphone/Maps/Core/Search/SearchIndex.swift +++ b/iphone/Maps/Core/Search/SearchIndex.swift @@ -20,14 +20,16 @@ final class SearchIndex: NSObject { init(suggestionsCount: Int, resultsCount: Int) { for index in 0.. MWMSearchItemType { - return items[index].type + func resultType(row: Int) -> MWMSearchItemType { + return items[row].type } - func resultContainerIndex(index: Int) -> Int { - return items[index].containerIndex + func resultContainerIndex(row: Int) -> Int { + return items[row].containerIndex } } diff --git a/iphone/Maps/UI/Search/TableView/MWMSearchTableViewController.mm b/iphone/Maps/UI/Search/TableView/MWMSearchTableViewController.mm index 0f0d2c5018..56a4cef26d 100644 --- a/iphone/Maps/UI/Search/TableView/MWMSearchTableViewController.mm +++ b/iphone/Maps/UI/Search/TableView/MWMSearchTableViewController.mm @@ -75,15 +75,15 @@ cellForRowAtIndexPath:(NSIndexPath *)indexPath { auto const row = indexPath.row; - auto const containerIndex = [MWMSearch containerIndexWithIndex:row]; - switch ([MWMSearch resultTypeWithIndex:row]) + auto const containerIndex = [MWMSearch containerIndexWithRow:row]; + switch ([MWMSearch resultTypeWithRow:row]) { case MWMSearchItemTypeRegular: { auto cell = static_cast([tableView dequeueReusableCellWithCellClass:[MWMSearchCommonCell class] indexPath:indexPath]); - auto result = [MWMSearch resultWithContainerIndex:containerIndex]; + auto const & result = [MWMSearch resultWithContainerIndex:containerIndex]; [cell config:result]; return cell; } @@ -100,7 +100,7 @@ auto cell = static_cast([tableView dequeueReusableCellWithCellClass:[MWMSearchSuggestionCell class] indexPath:indexPath]); - auto suggestion = [MWMSearch resultWithContainerIndex:containerIndex]; + auto const & suggestion = [MWMSearch resultWithContainerIndex:containerIndex]; [cell config:suggestion]; cell.isLastCell = row == [MWMSearch suggestionsCount] - 1; return cell; @@ -114,21 +114,21 @@ { id delegate = self.delegate; auto const row = indexPath.row; - auto const containerIndex = [MWMSearch containerIndexWithIndex:row]; - switch ([MWMSearch resultTypeWithIndex:row]) + auto const containerIndex = [MWMSearch containerIndexWithRow:row]; + switch ([MWMSearch resultTypeWithRow:row]) { case MWMSearchItemTypeRegular: { MWMSearchTextField * textField = delegate.searchTextField; [MWMSearch saveQuery:textField.text forInputLocale:textField.textInputMode.primaryLanguage]; - auto result = [MWMSearch resultWithContainerIndex:containerIndex]; + auto const & result = [MWMSearch resultWithContainerIndex:containerIndex]; [delegate processSearchWithResult:result]; break; } case MWMSearchItemTypeMopub: break; case MWMSearchItemTypeSuggestion: { - auto suggestion = [MWMSearch resultWithContainerIndex:containerIndex]; + auto const & suggestion = [MWMSearch resultWithContainerIndex:containerIndex]; NSString * suggestionString = @(suggestion.GetSuggestionString()); [Statistics logEvent:kStatEventName(kStatSearch, kStatSelectResult) withParameters:@{kStatValue : suggestionString, kStatScreen : kStatSearch}];