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

Side by Side Diff: ios/chrome/browser/ui/content_suggestions/content_suggestions_collection_updater.mm

Issue 2887073002: Layout Most Visited for ContentSuggestions (Closed)
Patch Set: Created 3 years, 7 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #import "ios/chrome/browser/ui/content_suggestions/content_suggestions_collectio n_updater.h" 5 #import "ios/chrome/browser/ui/content_suggestions/content_suggestions_collectio n_updater.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/mac/foundation_util.h" 8 #include "base/mac/foundation_util.h"
9 #include "base/strings/sys_string_conversions.h" 9 #include "base/strings/sys_string_conversions.h"
10 #include "base/time/time.h" 10 #include "base/time/time.h"
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 CSCollectionViewModel* model = 335 CSCollectionViewModel* model =
336 self.collectionViewController.collectionViewModel; 336 self.collectionViewController.collectionViewModel;
337 NSInteger sectionIdentifier = [model sectionIdentifierForSection:section]; 337 NSInteger sectionIdentifier = [model sectionIdentifierForSection:section];
338 ContentSuggestionsSectionInformation* sectionInfo = 338 ContentSuggestionsSectionInformation* sectionInfo =
339 self.sectionInfoBySectionIdentifier[@(sectionIdentifier)]; 339 self.sectionInfoBySectionIdentifier[@(sectionIdentifier)];
340 340
341 CSCollectionViewItem* item = [self emptyItemForSectionInfo:sectionInfo]; 341 CSCollectionViewItem* item = [self emptyItemForSectionInfo:sectionInfo];
342 return [self addItem:item toSectionWithIdentifier:sectionIdentifier]; 342 return [self addItem:item toSectionWithIdentifier:sectionIdentifier];
343 } 343 }
344 344
345 - (BOOL)isMostVisitedSection:(NSInteger)section {
346 return
347 [self.collectionViewController.collectionViewModel
348 sectionIdentifierForSection:section] == SectionIdentifierMostVisited;
349 }
350
345 #pragma mark - SuggestedContentDelegate 351 #pragma mark - SuggestedContentDelegate
346 352
347 - (void)loadImageForSuggestedItem:(CSCollectionViewItem*)suggestedItem { 353 - (void)loadImageForSuggestedItem:(CSCollectionViewItem*)suggestedItem {
348 __weak ContentSuggestionsCollectionUpdater* weakSelf = self; 354 __weak ContentSuggestionsCollectionUpdater* weakSelf = self;
349 __weak CSCollectionViewItem* weakItem = suggestedItem; 355 __weak CSCollectionViewItem* weakItem = suggestedItem;
350 356
351 void (^imageFetchedCallback)(UIImage*) = ^(UIImage* image) { 357 void (^imageFetchedCallback)(UIImage*) = ^(UIImage* image) {
352 ContentSuggestionsCollectionUpdater* strongSelf = weakSelf; 358 ContentSuggestionsCollectionUpdater* strongSelf = weakSelf;
353 CSCollectionViewItem* strongItem = weakItem; 359 CSCollectionViewItem* strongItem = weakItem;
354 if (!strongSelf || !strongItem) { 360 if (!strongSelf || !strongItem) {
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
521 CSCollectionViewModel* model = 527 CSCollectionViewModel* model =
522 self.collectionViewController.collectionViewModel; 528 self.collectionViewController.collectionViewModel;
523 NSInteger section = [model sectionForSectionIdentifier:sectionIdentifier]; 529 NSInteger section = [model sectionForSectionIdentifier:sectionIdentifier];
524 NSInteger itemNumber = [model numberOfItemsInSection:section]; 530 NSInteger itemNumber = [model numberOfItemsInSection:section];
525 [model addItem:item toSectionWithIdentifier:sectionIdentifier]; 531 [model addItem:item toSectionWithIdentifier:sectionIdentifier];
526 532
527 return [NSIndexPath indexPathForItem:itemNumber inSection:section]; 533 return [NSIndexPath indexPathForItem:itemNumber inSection:section];
528 } 534 }
529 535
530 @end 536 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698