mirror of
https://github.com/Instagram/IGListKit
synced 2026-05-23 17:28:22 +00:00
Move the display delegate invokation into IGListSectionController
Summary: Previously, IGListDisplayHandler took over the sectionController's displayDelegate and invoke directly. We have requirement in other cases where we want to control the displayDelegate invokation, e.t. Subclass of IGListSectionController can listen to the willDisplay/endDisplay events and do other processing. Moving the displayDelegate invokation inside IGListSectionController would allow us to have better control on the invokation timing. Differential Revision: D19973669 fbshipit-source-id: 33d23bc7efb235d2e1ed99737200e56bb320b678
This commit is contained in:
parent
bb89f70510
commit
e960e68c0f
3 changed files with 29 additions and 6 deletions
|
|
@ -100,4 +100,20 @@ void IGListSectionControllerPopThread(void) {
|
|||
IGFailAssert(@"Section controller %@ must override %s if interactive reordering is enabled.", self, __PRETTY_FUNCTION__);
|
||||
}
|
||||
|
||||
- (void)willDisplayCell:(UICollectionViewCell *)cell atIndex:(NSInteger)index listAdapter:(IGListAdapter *)listAdapter {
|
||||
[_displayDelegate listAdapter:listAdapter willDisplaySectionController:self cell:cell atIndex:index];
|
||||
}
|
||||
|
||||
- (void)didEndDisplayingCell:(UICollectionViewCell *)cell atIndex:(NSInteger)index listAdapter:(IGListAdapter *)listAdapter {
|
||||
[_displayDelegate listAdapter:listAdapter didEndDisplayingSectionController:self cell:cell atIndex:index];
|
||||
}
|
||||
|
||||
- (void)willDisplaySectionControllerWithListAdapter:(IGListAdapter *)listAdapter {
|
||||
[_displayDelegate listAdapter:listAdapter willDisplaySectionController:self];
|
||||
}
|
||||
|
||||
- (void)didEndDisplayingSectionControllerWithListAdapter:(IGListAdapter *)listAdapter {
|
||||
[_displayDelegate listAdapter:listAdapter didEndDisplayingSectionController:self];
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@
|
|||
#import <IGListKit/IGListAdapter.h>
|
||||
#import <IGListKit/IGListDisplayDelegate.h>
|
||||
#import <IGListKit/IGListSectionController.h>
|
||||
#import <IGListKit/IGListSectionControllerInternal.h>
|
||||
|
||||
@interface IGListDisplayHandler ()
|
||||
|
||||
|
|
@ -48,7 +49,7 @@
|
|||
[self.visibleViewObjectMap setObject:object forKey:view];
|
||||
NSCountedSet *visibleListSections = self.visibleListSections;
|
||||
if ([visibleListSections countForObject:sectionController] == 0) {
|
||||
[sectionController.displayDelegate listAdapter:listAdapter willDisplaySectionController:sectionController];
|
||||
[sectionController willDisplaySectionControllerWithListAdapter:listAdapter];
|
||||
[listAdapter.delegate listAdapter:listAdapter willDisplayObject:object atIndex:indexPath.section];
|
||||
}
|
||||
[visibleListSections addObject:sectionController];
|
||||
|
|
@ -73,7 +74,7 @@
|
|||
[visibleSections removeObject:sectionController];
|
||||
|
||||
if ([visibleSections countForObject:sectionController] == 0) {
|
||||
[sectionController.displayDelegate listAdapter:listAdapter didEndDisplayingSectionController:sectionController];
|
||||
[sectionController didEndDisplayingSectionControllerWithListAdapter:listAdapter];
|
||||
[listAdapter.delegate listAdapter:listAdapter didEndDisplayingObject:object atIndex:section];
|
||||
}
|
||||
}
|
||||
|
|
@ -100,8 +101,7 @@
|
|||
sectionController:(IGListSectionController *)sectionController
|
||||
object:(id)object
|
||||
indexPath:(NSIndexPath *)indexPath {
|
||||
id <IGListDisplayDelegate> displayDelegate = [sectionController displayDelegate];
|
||||
[displayDelegate listAdapter:listAdapter willDisplaySectionController:sectionController cell:cell atIndex:indexPath.item];
|
||||
[sectionController willDisplayCell:cell atIndex:indexPath.item listAdapter:listAdapter];
|
||||
[self _willDisplayReusableView:cell forListAdapter:listAdapter sectionController:sectionController object:object indexPath:indexPath];
|
||||
}
|
||||
|
||||
|
|
@ -114,8 +114,7 @@
|
|||
if (object == nil) {
|
||||
return;
|
||||
}
|
||||
|
||||
[sectionController.displayDelegate listAdapter:listAdapter didEndDisplayingSectionController:sectionController cell:cell atIndex:indexPath.item];
|
||||
[sectionController didEndDisplayingCell:cell atIndex:indexPath.item listAdapter:listAdapter];
|
||||
[self _didEndDisplayingReusableView:cell forListAdapter:listAdapter sectionController:sectionController object:object indexPath:indexPath];
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -28,4 +28,12 @@ FOUNDATION_EXTERN void IGListSectionControllerPopThread(void);
|
|||
*/
|
||||
- (BOOL)canMoveItemAtIndex:(NSInteger)sourceItemIndex toIndex:(NSInteger)destinationItemIndex;
|
||||
|
||||
- (void)willDisplayCell:(UICollectionViewCell *)cell atIndex:(NSInteger)index listAdapter:(IGListAdapter *)listAdapter;
|
||||
|
||||
- (void)didEndDisplayingCell:(UICollectionViewCell *)cell atIndex:(NSInteger)index listAdapter:(IGListAdapter *)listAdapter;
|
||||
|
||||
- (void)willDisplaySectionControllerWithListAdapter:(IGListAdapter *)listAdapter;
|
||||
|
||||
- (void)didEndDisplayingSectionControllerWithListAdapter:(IGListAdapter *)listAdapter;
|
||||
|
||||
@end
|
||||
|
|
|
|||
Loading…
Reference in a new issue