[WIP] Trigger new batch fetch for collection view after layout transitions (#1697)

[Table / Collection] Trigger new batch fetch after programmatic scrolls, or layout transitions.
This commit is contained in:
Nick Velloff
2016-06-22 16:21:10 -07:00
committed by appleguy
parent eb9e8167c3
commit a05d3119ad
4 changed files with 19 additions and 0 deletions

View File

@@ -1002,6 +1002,7 @@ static NSString * const kCellReuseIdentifier = @"_ASCollectionViewCell";
- (NSArray *)visibleNodeIndexPathsForRangeController:(ASRangeController *)rangeController
{
ASDisplayNodeAssertMainThread();
// Calling visibleNodeIndexPathsForRangeController: will trigger UIKit to call reloadData if it never has, which can result
// in incorrect layout if performed at zero size. We can use the fact that nothing can be visible at zero size to return fast.
BOOL isZeroSized = CGRectEqualToRect(self.bounds, CGRectZero);
@@ -1065,6 +1066,11 @@ static NSString * const kCellReuseIdentifier = @"_ASCollectionViewCell";
_performingBatchUpdates = NO;
}
- (void)didCompleteUpdatesInRangeController:(ASRangeController *)rangeController
{
[self _checkForBatchFetching];
}
- (void)rangeController:(ASRangeController *)rangeController didInsertNodes:(NSArray *)nodes atIndexPaths:(NSArray *)indexPaths withAnimationOptions:(ASDataControllerAnimationOptions)animationOptions
{
ASDisplayNodeAssertMainThread();

View File

@@ -968,6 +968,11 @@ static NSString * const kCellReuseIdentifier = @"_ASTableViewCell";
}
}
- (void)didCompleteUpdatesInRangeController:(ASRangeController *)rangeController
{
[self _checkForBatchFetching];
}
- (void)rangeController:(ASRangeController *)rangeController didInsertNodes:(NSArray *)nodes atIndexPaths:(NSArray *)indexPaths withAnimationOptions:(ASDataControllerAnimationOptions)animationOptions
{
ASDisplayNodeAssertMainThread();

View File

@@ -146,6 +146,13 @@ NS_ASSUME_NONNULL_BEGIN
*/
- (void)rangeController:(ASRangeController * )rangeController didEndUpdatesAnimated:(BOOL)animated completion:(void (^)(BOOL))completion;
/**
* Completed updates to cell node addition and removal.
*
* @param rangeController Sender.
*/
- (void)didCompleteUpdatesInRangeController:(ASRangeController *)rangeController;
/**
* Called for nodes insertion.
*

View File

@@ -333,6 +333,7 @@ static UIApplicationState __ApplicationState = UIApplicationStateActive;
[modifiedIndexPaths sortUsingSelector:@selector(compare:)];
NSLog(@"Range update complete; modifiedIndexPaths: %@", [self descriptionWithIndexPaths:modifiedIndexPaths]);
#endif
[_delegate didCompleteUpdatesInRangeController:self];
}
#pragma mark - Notification observers