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

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

Issue 2741343005: ContentSuggestions collection adds items with animation (Closed)
Patch Set: Rebase on correct head 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 unified diff | Download patch
« no previous file with comments | « ios/chrome/browser/ui/content_suggestions/content_suggestions_view_controller.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_view_cont roller.h" 5 #import "ios/chrome/browser/ui/content_suggestions/content_suggestions_view_cont roller.h"
6 6
7 #include "base/mac/foundation_util.h" 7 #include "base/mac/foundation_util.h"
8 #import "ios/chrome/browser/ui/collection_view/cells/MDCCollectionViewCell+Chrom e.h" 8 #import "ios/chrome/browser/ui/collection_view/cells/MDCCollectionViewCell+Chrom e.h"
9 #import "ios/chrome/browser/ui/collection_view/cells/collection_view_item.h" 9 #import "ios/chrome/browser/ui/collection_view/cells/collection_view_item.h"
10 #import "ios/chrome/browser/ui/collection_view/collection_view_model.h" 10 #import "ios/chrome/browser/ui/collection_view/collection_view_model.h"
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 [self.collectionView performBatchUpdates:^{ 82 [self.collectionView performBatchUpdates:^{
83 [self.collectionViewModel removeSectionWithIdentifier:sectionIdentifier]; 83 [self.collectionViewModel removeSectionWithIdentifier:sectionIdentifier];
84 [self.collectionView deleteSections:[NSIndexSet indexSetWithIndex:section]]; 84 [self.collectionView deleteSections:[NSIndexSet indexSetWithIndex:section]];
85 } 85 }
86 completion:^(BOOL) { 86 completion:^(BOOL) {
87 // The context menu could be displayed for the deleted entries. 87 // The context menu could be displayed for the deleted entries.
88 [self.suggestionCommandHandler dismissContextMenu]; 88 [self.suggestionCommandHandler dismissContextMenu];
89 }]; 89 }];
90 } 90 }
91 91
92 - (void)addSuggestions:(NSArray<ContentSuggestion*>*)suggestions {
93 if (suggestions.count == 0) {
94 return;
95 }
96
97 [self.collectionView performBatchUpdates:^{
98 NSIndexSet* addedSections =
99 [self.collectionUpdater addSectionsForSuggestionsToModel:suggestions];
100 [self.collectionView insertSections:addedSections];
101 }
102 completion:nil];
103
104 [self.collectionView performBatchUpdates:^{
105 NSArray<NSIndexPath*>* addedItems =
106 [self.collectionUpdater addSuggestionsToModel:suggestions];
107 [self.collectionView insertItemsAtIndexPaths:addedItems];
108 }
109 completion:nil];
110 }
111
92 #pragma mark - UIViewController 112 #pragma mark - UIViewController
93 113
94 - (void)viewDidLoad { 114 - (void)viewDidLoad {
95 [super viewDidLoad]; 115 [super viewDidLoad];
96 116
97 _collectionUpdater.collectionViewController = self; 117 _collectionUpdater.collectionViewController = self;
98 118
99 self.collectionView.delegate = self; 119 self.collectionView.delegate = self;
100 self.styler.cellStyle = MDCCollectionViewCellStyleCard; 120 self.styler.cellStyle = MDCCollectionViewCellStyleCard;
101 121
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 ContentSuggestionsArticleItem* articleItem = 255 ContentSuggestionsArticleItem* articleItem =
236 base::mac::ObjCCastStrict<ContentSuggestionsArticleItem>(touchedItem); 256 base::mac::ObjCCastStrict<ContentSuggestionsArticleItem>(touchedItem);
237 257
238 [self.suggestionCommandHandler 258 [self.suggestionCommandHandler
239 displayContextMenuForArticle:articleItem 259 displayContextMenuForArticle:articleItem
240 atPoint:touchLocation 260 atPoint:touchLocation
241 atIndexPath:touchedItemIndexPath]; 261 atIndexPath:touchedItemIndexPath];
242 } 262 }
243 263
244 @end 264 @end
OLDNEW
« no previous file with comments | « ios/chrome/browser/ui/content_suggestions/content_suggestions_view_controller.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698