Levi's comments

This commit is contained in:
Bin Liu 2016-01-27 15:05:56 -08:00
parent f6be279c60
commit b26337c449
2 changed files with 18 additions and 25 deletions

View File

@ -876,13 +876,13 @@ static NSString * const kCellReuseIdentifier = @"_ASCollectionViewCell";
} }
if (_performingBatchUpdates) { if (_performingBatchUpdates) {
[_layoutFacilitator collectionViewBatchingCellEditsAtIndexPaths:indexPaths]; [_layoutFacilitator collectionViewWillEditCellsAtIndexPaths:indexPaths batched:YES];
[_batchUpdateBlocks addObject:^{ [_batchUpdateBlocks addObject:^{
[super insertItemsAtIndexPaths:indexPaths]; [super insertItemsAtIndexPaths:indexPaths];
}]; }];
} else { } else {
[_layoutFacilitator collectionViewWillEditCellsAtIndexPaths:indexPaths batched:NO];
[UIView performWithoutAnimation:^{ [UIView performWithoutAnimation:^{
[_layoutFacilitator collectionViewEditingCellsAtIndexPaths:indexPaths];
[super insertItemsAtIndexPaths:indexPaths]; [super insertItemsAtIndexPaths:indexPaths];
}]; }];
} }
@ -891,19 +891,18 @@ static NSString * const kCellReuseIdentifier = @"_ASCollectionViewCell";
- (void)rangeController:(ASRangeController *)rangeController didDeleteNodes:(NSArray *)nodes atIndexPaths:(NSArray *)indexPaths withAnimationOptions:(ASDataControllerAnimationOptions)animationOptions - (void)rangeController:(ASRangeController *)rangeController didDeleteNodes:(NSArray *)nodes atIndexPaths:(NSArray *)indexPaths withAnimationOptions:(ASDataControllerAnimationOptions)animationOptions
{ {
ASDisplayNodeAssertMainThread(); ASDisplayNodeAssertMainThread();
[_layoutFacilitator collectionViewEditingCellsAtIndexPaths:indexPaths];
if (!self.asyncDataSource || _superIsPendingDataLoad) { if (!self.asyncDataSource || _superIsPendingDataLoad) {
return; // if the asyncDataSource has become invalid while we are processing, ignore this request to avoid crashes return; // if the asyncDataSource has become invalid while we are processing, ignore this request to avoid crashes
} }
if (_performingBatchUpdates) { if (_performingBatchUpdates) {
[_layoutFacilitator collectionViewBatchingCellEditsAtIndexPaths:indexPaths]; [_layoutFacilitator collectionViewWillEditCellsAtIndexPaths:indexPaths batched:YES];
[_batchUpdateBlocks addObject:^{ [_batchUpdateBlocks addObject:^{
[super deleteItemsAtIndexPaths:indexPaths]; [super deleteItemsAtIndexPaths:indexPaths];
}]; }];
} else { } else {
[_layoutFacilitator collectionViewWillEditCellsAtIndexPaths:indexPaths batched:NO];
[UIView performWithoutAnimation:^{ [UIView performWithoutAnimation:^{
[_layoutFacilitator collectionViewEditingCellsAtIndexPaths:indexPaths];
[super deleteItemsAtIndexPaths:indexPaths]; [super deleteItemsAtIndexPaths:indexPaths];
}]; }];
} }
@ -917,13 +916,13 @@ static NSString * const kCellReuseIdentifier = @"_ASCollectionViewCell";
} }
if (_performingBatchUpdates) { if (_performingBatchUpdates) {
[_layoutFacilitator collectionViewBatchingSectionEditsAtIndexes:indexSet]; [_layoutFacilitator collectionViewWillEditSectionsAtIndexSet:indexSet batched:YES];
[_batchUpdateBlocks addObject:^{ [_batchUpdateBlocks addObject:^{
[super insertSections:indexSet]; [super insertSections:indexSet];
}]; }];
} else { } else {
[_layoutFacilitator collectionViewWillEditSectionsAtIndexSet:indexSet batched:NO];
[UIView performWithoutAnimation:^{ [UIView performWithoutAnimation:^{
[_layoutFacilitator collectionViewEditingSectionsAtIndexSet:indexSet];
[super insertSections:indexSet]; [super insertSections:indexSet];
}]; }];
} }
@ -937,13 +936,13 @@ static NSString * const kCellReuseIdentifier = @"_ASCollectionViewCell";
} }
if (_performingBatchUpdates) { if (_performingBatchUpdates) {
[_layoutFacilitator collectionViewBatchingSectionEditsAtIndexes:indexSet]; [_layoutFacilitator collectionViewWillEditSectionsAtIndexSet:indexSet batched:YES];
[_batchUpdateBlocks addObject:^{ [_batchUpdateBlocks addObject:^{
[super deleteSections:indexSet]; [super deleteSections:indexSet];
}]; }];
} else { } else {
[_layoutFacilitator collectionViewWillEditSectionsAtIndexSet:indexSet batched:NO];
[UIView performWithoutAnimation:^{ [UIView performWithoutAnimation:^{
[_layoutFacilitator collectionViewEditingSectionsAtIndexSet:indexSet];
[super deleteSections:indexSet]; [super deleteSections:indexSet];
}]; }];
} }

View File

@ -17,29 +17,23 @@
/** /**
* Inform that the collectionView is editing the cells at a list of indexPaths * Inform that the collectionView is editing the cells at a list of indexPaths
*
* @param indexPaths, an array of NSIndexPath objects of cells being/will be edited.
* @param isBatched, indicates whether the editing operation will be batched by the collectionView
*
* NOTE: when isBatched, used in combination with -collectionViewWillPerformBatchUpdates
*/ */
- (void)collectionViewEditingCellsAtIndexPaths:(NSArray *)indexPaths; - (void)collectionViewWillEditCellsAtIndexPaths:(NSArray *)indexPaths batched:(BOOL)isBatched;
/** /**
* Inform that the collectionView is editing the sections at a set of indexes * Inform that the collectionView is editing the sections at a set of indexes
*/
- (void)collectionViewEditingSectionsAtIndexSet:(NSIndexSet *)indexes;
/**
* Inform that the collectionView is adding some cell updates into a batch,
* and will perform these batch updates at a later point
* *
* NOTE: used in combination with -collectionViewWillPerformBatchUpdates * @param indexes, an NSIndexSet of section indexes being/will be edited.
*/ * @param isBatched, indicates whether the editing operation will be batched by the collectionView
- (void)collectionViewBatchingCellEditsAtIndexPaths:(NSArray *)indexPaths;
/**
* Inform that the collectionView is adding some section updates into a batch,
* and will perform these batch updates at a later point
* *
* NOTE: used in combination with -collectionViewWillPerformBatchUpdates * NOTE: when isBatched, used in combination with -collectionViewWillPerformBatchUpdates
*/ */
- (void)collectionViewBatchingSectionEditsAtIndexes:(NSIndexSet *)indexes; - (void)collectionViewWillEditSectionsAtIndexSet:(NSIndexSet *)indexes batched:(BOOL)batched;
/** /**
* Informs the delegate that the collectionView is about to call performBatchUpdates * Informs the delegate that the collectionView is about to call performBatchUpdates