Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(80)

Unified Diff: ios/chrome/browser/ui/collection_view/collection_view_model.mm

Issue 2761263003: Allow CollectionViewModel/Controller queries without SectionIdentifier (Closed)
Patch Set: Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ios/chrome/browser/ui/collection_view/collection_view_model.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/chrome/browser/ui/collection_view/collection_view_model.mm
diff --git a/ios/chrome/browser/ui/collection_view/collection_view_model.mm b/ios/chrome/browser/ui/collection_view/collection_view_model.mm
index 0866b37bdafde7636ef71ab9c88f608417224f14..460091ffc9a7435bbbc74e89834abac1689c72fa 100644
--- a/ios/chrome/browser/ui/collection_view/collection_view_model.mm
+++ b/ios/chrome/browser/ui/collection_view/collection_view_model.mm
@@ -267,6 +267,25 @@ typedef NSMutableArray<CollectionViewItem*> SectionItems;
return [NSIndexPath indexPathForItem:itemIndex inSection:section];
}
+- (BOOL)hasItem:(CollectionViewItem*)item {
+ for (SectionItems* sectionItems in _sections) {
+ if ([sectionItems indexOfObject:item] != NSNotFound)
+ return YES;
+ }
+ return NO;
+}
+
+- (NSIndexPath*)indexPathForItem:(CollectionViewItem*)item {
+ for (NSUInteger section = 0; section < [_sections count]; section++) {
+ NSInteger itemIndex = [_sections[section] indexOfObject:item];
+ if (itemIndex != NSNotFound) {
+ return [NSIndexPath indexPathForItem:itemIndex inSection:section];
+ }
+ }
+ DCHECK(NO);
lpromero 2017/03/22 14:04:22 Use NOTREACHED.
+ return nil;
+}
+
#pragma mark UICollectionView data sourcing
- (NSInteger)numberOfSections {
« no previous file with comments | « ios/chrome/browser/ui/collection_view/collection_view_model.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698