Index: ios/chrome/browser/ui/reading_list/reading_list_collection_view_controller.mm |
diff --git a/ios/chrome/browser/ui/reading_list/reading_list_collection_view_controller.mm b/ios/chrome/browser/ui/reading_list/reading_list_collection_view_controller.mm |
index 45ddedcb46aa2cbe98740f295fb18d39eb02665a..08a53fc0e8d826074697c999ec150ee72dc60aae 100644 |
--- a/ios/chrome/browser/ui/reading_list/reading_list_collection_view_controller.mm |
+++ b/ios/chrome/browser/ui/reading_list/reading_list_collection_view_controller.mm |
@@ -52,10 +52,9 @@ typedef NS_ENUM(NSInteger, SectionIdentifier) { |
}; |
typedef NS_ENUM(NSInteger, ItemType) { |
- ItemTypeUnreadHeader = kItemTypeEnumZero, |
- ItemTypeUnread, |
- ItemTypeReadHeader, |
- ItemTypeRead, |
+ ItemTypeHeader = kItemTypeEnumZero, |
+ ItemTypeItem, |
+ ItemTypeItemDetails, |
}; |
// Typedef for a block taking a GURL as parameter and returning nothing. |
@@ -329,10 +328,16 @@ using ItemsMapByDate = std::multimap<int64_t, ReadingListCollectionViewItem*>; |
- (CGFloat)collectionView:(UICollectionView*)collectionView |
cellHeightAtIndexPath:(NSIndexPath*)indexPath { |
NSInteger type = [self.collectionViewModel itemTypeForIndexPath:indexPath]; |
- if (type == ItemTypeUnread || type == ItemTypeRead) |
- return MDCCellDefaultTwoLineHeight; |
- else |
- return MDCCellDefaultOneLineHeight; |
+ switch (type) { |
+ case ItemTypeHeader: |
+ return MDCCellDefaultOneLineHeight; |
+ case ItemTypeItem: |
+ return MDCCellDefaultTwoLineHeight; |
+ case ItemTypeItemDetails: |
+ return MDCCellDefaultThreeLineHeight; |
+ } |
+ NOTREACHED(); |
+ return 0; |
} |
#pragma mark - MDCCollectionViewEditingDelegate |
@@ -598,9 +603,11 @@ using ItemsMapByDate = std::multimap<int64_t, ReadingListCollectionViewItem*>; |
ReadingListCollectionViewItem* oldItem = |
base::mac::ObjCCastStrict<ReadingListCollectionViewItem>(items[index]); |
ReadingListCollectionViewItem* newItem = iterator->second; |
- if (oldItem.url == newItem.url) { |
- oldItem.text = newItem.text; |
+ if (oldItem.url == newItem.url && oldItem.type == newItem.type) { |
gambard
2017/03/16 07:50:23
This is my main concern.
I don't see how this woul
Olivier
2017/03/16 09:20:14
I guess you don't reload the "Read" section.
Do yo
|
+ oldItem.title = newItem.title; |
oldItem.distillationState = newItem.distillationState; |
+ oldItem.distillationDate = newItem.distillationDate; |
+ oldItem.distillationSize = newItem.distillationSize; |
oldItem.faviconPageURL = newItem.faviconPageURL; |
} |
if (![oldItem isEqual:newItem]) { |
@@ -614,15 +621,21 @@ using ItemsMapByDate = std::multimap<int64_t, ReadingListCollectionViewItem*>; |
- (ReadingListCollectionViewItem*)cellItemForReadingListEntry: |
(const ReadingListEntry&)entry { |
GURL url = entry.URL(); |
+ BOOL has_distillation_details = |
+ entry.DistilledState() == ReadingListEntry::PROCESSED && |
+ entry.DistillationSize() != 0 && entry.DistillationTime() != 0; |
ReadingListCollectionViewItem* item = [[ReadingListCollectionViewItem alloc] |
- initWithType:entry.IsRead() ? ItemTypeRead : ItemTypeUnread |
+ initWithType:has_distillation_details ? ItemTypeItemDetails |
+ : ItemTypeItem |
attributesProvider:self.attributesProvider |
url:url |
distillationState:entry.DistilledState()]; |
NSString* urlString = base::SysUTF16ToNSString(url_formatter::FormatUrl(url)); |
NSString* title = base::SysUTF8ToNSString(entry.Title()); |
- item.text = [title length] ? title : urlString; |
- item.detailText = urlString; |
+ item.title = [title length] ? title : urlString; |
+ item.subtitle = urlString; |
+ item.distillationDate = entry.DistillationTime(); |
+ item.distillationSize = entry.DistillationSize(); |
item.faviconPageURL = |
entry.DistilledURL().is_valid() ? entry.DistilledURL() : url; |
return item; |
@@ -1136,13 +1149,12 @@ using ItemsMapByDate = std::multimap<int64_t, ReadingListCollectionViewItem*>; |
switch (sectionIdentifier) { |
case SectionIdentifierRead: |
- header = [[CollectionViewTextItem alloc] initWithType:ItemTypeReadHeader]; |
+ header = [[CollectionViewTextItem alloc] initWithType:ItemTypeHeader]; |
header.text = l10n_util::GetNSString(IDS_IOS_READING_LIST_READ_HEADER); |
break; |
case SectionIdentifierUnread: |
- header = |
- [[CollectionViewTextItem alloc] initWithType:ItemTypeUnreadHeader]; |
+ header = [[CollectionViewTextItem alloc] initWithType:ItemTypeHeader]; |
header.text = l10n_util::GetNSString(IDS_IOS_READING_LIST_UNREAD_HEADER); |
break; |
} |