Chromium Code Reviews| Index: ios/chrome/browser/ui/payments/payment_request_selector_view_controller.mm |
| diff --git a/ios/chrome/browser/ui/payments/payment_request_selector_view_controller.mm b/ios/chrome/browser/ui/payments/payment_request_selector_view_controller.mm |
| index 339f5b5f84a193cd0f69325f62b1cae1148896f9..333d342266a5bf1a5dd2e88c77465bb24d36f454 100644 |
| --- a/ios/chrome/browser/ui/payments/payment_request_selector_view_controller.mm |
| +++ b/ios/chrome/browser/ui/payments/payment_request_selector_view_controller.mm |
| @@ -261,31 +261,30 @@ typedef NS_ENUM(NSInteger, ItemType) { |
| switch (item.type) { |
| case ItemTypeSelectableItem: { |
| - CollectionViewItem<PaymentsIsSelectable>* newSelectedItem = |
| - reinterpret_cast<CollectionViewItem<PaymentsIsSelectable>*>(item); |
| - // Update the currently selected and the newly selected cells only if the |
| - // newly selected cell corresponds to a complete item and can be selected. |
| - if (newSelectedItem.isComplete) { |
| + NSUInteger currentlySelectedItemIndex = self.dataSource.selectedItemIndex; |
| + // Notify the delegate of the selection. Update the currently selected and |
| + // the newly selected cells only if the selection can actually be made. |
| + NSUInteger index = |
| + [self.collectionViewModel indexInItemTypeForIndexPath:indexPath]; |
| + DCHECK(index < [[self.dataSource selectableItems] count]); |
|
macourteau
2017/06/28 19:11:42
nit: DCHECK_LT ?
Moe
2017/06/29 01:34:02
Done.
|
| + if ([self.delegate paymentRequestSelectorViewController:self |
| + didSelectItemAtIndex:index]) { |
| // Update the currently selected cell, if any. |
| - if (self.dataSource.selectedItemIndex != NSUIntegerMax) { |
| - DCHECK(self.dataSource.selectedItemIndex < |
| + if (currentlySelectedItemIndex != NSUIntegerMax) { |
| + DCHECK(currentlySelectedItemIndex < |
| [[self.dataSource selectableItems] count]); |
| CollectionViewItem<PaymentsIsSelectable>* oldSelectedItem = |
| [[self.dataSource selectableItems] |
| - objectAtIndex:self.dataSource.selectedItemIndex]; |
| + objectAtIndex:currentlySelectedItemIndex]; |
| oldSelectedItem.accessoryType = MDCCollectionViewCellAccessoryNone; |
| [self reconfigureCellsForItems:@[ oldSelectedItem ]]; |
| } |
| // Update the newly selected cell. |
| + CollectionViewItem<PaymentsIsSelectable>* newSelectedItem = |
| + reinterpret_cast<CollectionViewItem<PaymentsIsSelectable>*>(item); |
| newSelectedItem.accessoryType = MDCCollectionViewCellAccessoryCheckmark; |
| [self reconfigureCellsForItems:@[ newSelectedItem ]]; |
| } |
| - // Notify the delegate of the selection. |
| - NSUInteger index = |
| - [self.collectionViewModel indexInItemTypeForIndexPath:indexPath]; |
| - DCHECK(index < [[self.dataSource selectableItems] count]); |
| - [self.delegate paymentRequestSelectorViewController:self |
| - didSelectItemAtIndex:index]; |
| break; |
| } |
| case ItemTypeAddItem: { |