| OLD | NEW |
| 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 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 self.styler.cellStyle = MDCCollectionViewCellStyleCard; | 117 self.styler.cellStyle = MDCCollectionViewCellStyleCard; |
| 118 | 118 |
| 119 UILongPressGestureRecognizer* longPressRecognizer = | 119 UILongPressGestureRecognizer* longPressRecognizer = |
| 120 [[UILongPressGestureRecognizer alloc] | 120 [[UILongPressGestureRecognizer alloc] |
| 121 initWithTarget:self | 121 initWithTarget:self |
| 122 action:@selector(handleLongPress:)]; | 122 action:@selector(handleLongPress:)]; |
| 123 longPressRecognizer.numberOfTouchesRequired = 1; | 123 longPressRecognizer.numberOfTouchesRequired = 1; |
| 124 [self.collectionView addGestureRecognizer:longPressRecognizer]; | 124 [self.collectionView addGestureRecognizer:longPressRecognizer]; |
| 125 } | 125 } |
| 126 | 126 |
| 127 - (void)viewWillTransitionToSize:(CGSize)size |
| 128 withTransitionCoordinator: |
| 129 (id<UIViewControllerTransitionCoordinator>)coordinator { |
| 130 [self.collectionUpdater updateMostVisitedForSize:size]; |
| 131 } |
| 132 |
| 127 #pragma mark - UICollectionViewDelegate | 133 #pragma mark - UICollectionViewDelegate |
| 128 | 134 |
| 129 - (void)collectionView:(UICollectionView*)collectionView | 135 - (void)collectionView:(UICollectionView*)collectionView |
| 130 didSelectItemAtIndexPath:(NSIndexPath*)indexPath { | 136 didSelectItemAtIndexPath:(NSIndexPath*)indexPath { |
| 131 [super collectionView:collectionView didSelectItemAtIndexPath:indexPath]; | 137 [super collectionView:collectionView didSelectItemAtIndexPath:indexPath]; |
| 132 | 138 |
| 133 CollectionViewItem* item = | 139 CollectionViewItem* item = |
| 134 [self.collectionViewModel itemAtIndexPath:indexPath]; | 140 [self.collectionViewModel itemAtIndexPath:indexPath]; |
| 135 switch ([self.collectionUpdater contentSuggestionTypeForItem:item]) { | 141 switch ([self.collectionUpdater contentSuggestionTypeForItem:item]) { |
| 136 case ContentSuggestionTypeReadingList: | 142 case ContentSuggestionTypeReadingList: |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 - (void)addEmptySectionPlaceholderIfNeeded:(NSInteger)section { | 265 - (void)addEmptySectionPlaceholderIfNeeded:(NSInteger)section { |
| 260 if ([self.collectionViewModel numberOfItemsInSection:section] > 0) | 266 if ([self.collectionViewModel numberOfItemsInSection:section] > 0) |
| 261 return; | 267 return; |
| 262 | 268 |
| 263 NSIndexPath* emptyItem = | 269 NSIndexPath* emptyItem = |
| 264 [self.collectionUpdater addEmptyItemForSection:section]; | 270 [self.collectionUpdater addEmptyItemForSection:section]; |
| 265 [self.collectionView insertItemsAtIndexPaths:@[ emptyItem ]]; | 271 [self.collectionView insertItemsAtIndexPaths:@[ emptyItem ]]; |
| 266 } | 272 } |
| 267 | 273 |
| 268 @end | 274 @end |
| OLD | NEW |