Remove IGListBindingSingleSectionController's displayDelegate override

Summary:
There is a KP in IGListBindingSingleSectionController that we need to override the `displayDelegate` in order to track the displayingCell for performant update, when the section controller is not visible.

With the newly refactoring in how IGListSectionController handles the displaying events, IGListBindingSingleSectionController can now override the willDisplay/endDisplay calls without manually adding itself as the `displayDelegate`, the behavior works as before.

Differential Revision: D19973670

fbshipit-source-id: 1f9fec1bf88aa8755c163c636ebb49b377e6873c
This commit is contained in:
Zhisheng Huang 2020-02-20 15:20:51 -08:00 committed by Facebook Github Bot
parent e960e68c0f
commit 6dfdce1d5e

View file

@ -8,8 +8,9 @@
#import "IGListBindingSingleSectionController.h"
#import <IGListDiffKit/IGListAssert.h>
#import "IGListSectionControllerInternal.h"
@interface IGListBindingSingleSectionController () <IGListDisplayDelegate>
@interface IGListBindingSingleSectionController ()
@end
@ -18,13 +19,6 @@
__weak UICollectionViewCell *_displayingCell;
}
- (instancetype)init {
if (self = [super init]) {
self.displayDelegate = self;
}
return self;
}
- (void)didSelectItemWithCell:(UICollectionViewCell *)cell {
// no-op
}
@ -55,28 +49,6 @@
return CGSizeZero;
}
#pragma mark - IGListDisplayDelegate
- (void)listAdapter:(nonnull IGListAdapter *)listAdapter willDisplaySectionController:(nonnull IGListSectionController *)sectionController {
// no-op
}
- (void)listAdapter:(nonnull IGListAdapter *)listAdapter didEndDisplayingSectionController:(nonnull IGListSectionController *)sectionController {
// no-op
}
- (void)listAdapter:(nonnull IGListAdapter *)listAdapter willDisplaySectionController:(nonnull IGListSectionController *)sectionController cell:(nonnull UICollectionViewCell *)cell atIndex:(NSInteger)index {
IGParameterAssert(index == 0);
_displayingCell = cell;
}
- (void)listAdapter:(nonnull IGListAdapter *)listAdapter didEndDisplayingSectionController:(nonnull IGListSectionController *)sectionController cell:(nonnull UICollectionViewCell *)cell atIndex:(NSInteger)index {
IGParameterAssert(index == 0);
if (cell == _displayingCell) {
_displayingCell = nil;
}
}
#pragma mark - IGListSectionController Overrides
- (NSInteger)numberOfItems {
@ -130,4 +102,18 @@
[self didUnhighlightItemWithCell:cell];
}
- (void)willDisplayCell:(UICollectionViewCell *)cell atIndex:(NSInteger)index listAdapter:(IGListAdapter *)listAdapter {
IGParameterAssert(index == 0);
_displayingCell = cell;
[super willDisplayCell:cell atIndex:index listAdapter:listAdapter];
}
- (void)didEndDisplayingCell:(UICollectionViewCell *)cell atIndex:(NSInteger)index listAdapter:(IGListAdapter *)listAdapter {
IGParameterAssert(index == 0);
if (cell == _displayingCell) {
_displayingCell = nil;
}
[super didEndDisplayingCell:cell atIndex:index listAdapter:listAdapter];
}
@end