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

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

Issue 2761263003: Allow CollectionViewModel/Controller queries without SectionIdentifier (Closed)
Patch Set: Add reconfigure to the VC 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) {
lpromero 2017/03/28 09:09:08 Iterate on _sectionIdentifiers and use haseItem:in
gambard 2017/03/28 13:35:22 I wanted to offer a solution without the current i
+ if ([sectionItems indexOfObject:item] != NSNotFound)
+ return YES;
+ }
+ return NO;
+}
+
+- (NSIndexPath*)indexPathForItem:(CollectionViewItem*)item {
+ for (NSUInteger section = 0; section < [_sections count]; section++) {
lpromero 2017/03/28 09:09:08 Idem, use the same methods that use the sectionIde
gambard 2017/03/28 13:35:22 This method was slightly more efficient (lookup on
+ NSInteger itemIndex = [_sections[section] indexOfObject:item];
+ if (itemIndex != NSNotFound) {
+ return [NSIndexPath indexPathForItem:itemIndex inSection:section];
+ }
+ }
+ DCHECK(NO);
lpromero 2017/03/28 09:09:08 Use NOTREACHED().
gambard 2017/03/28 13:35:22 Done.
+ 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