Add batch animation

This commit is contained in:
Li Tan
2015-01-08 16:09:27 -08:00
parent 42f801f269
commit 00e2f46c8d
5 changed files with 183 additions and 114 deletions

View File

@@ -213,7 +213,7 @@ static BOOL _isInterceptedSelector(SEL sel)
- (void)beginUpdates
{
[self throwUnimplementedException];
[_dataController beginUpdates];
}
- (void)endUpdates
@@ -223,17 +223,17 @@ static BOOL _isInterceptedSelector(SEL sel)
- (void)insertSections:(NSIndexSet *)sections withRowAnimation:(UITableViewRowAnimation)animation
{
[_dataController insertSections:sections];
[_dataController insertSections:sections withAnimationOption:animation];
}
- (void)deleteSections:(NSIndexSet *)sections withRowAnimation:(UITableViewRowAnimation)animation
{
[_dataController deleteSections:sections];
[_dataController deleteSections:sections withAnimationOption:animation];
}
- (void)reloadSections:(NSIndexSet *)sections withRowAnimation:(UITableViewRowAnimation)animation
{
[_dataController reloadSections:sections];
[_dataController reloadSections:sections withAnimationOption:animation];
}
- (void)moveSection:(NSInteger)section toSection:(NSInteger)newSection
@@ -243,17 +243,17 @@ static BOOL _isInterceptedSelector(SEL sel)
- (void)insertRowsAtIndexPaths:(NSArray *)indexPaths withRowAnimation:(UITableViewRowAnimation)animation
{
[_dataController insertRowsAtIndexPaths:indexPaths];
[_dataController insertRowsAtIndexPaths:indexPaths withAnimationOption:animation];
}
- (void)deleteRowsAtIndexPaths:(NSArray *)indexPaths withRowAnimation:(UITableViewRowAnimation)animation
{
[_dataController deleteRowsAtIndexPaths:indexPaths];
[_dataController deleteRowsAtIndexPaths:indexPaths withAnimationOption:animation];
}
- (void)reloadRowsAtIndexPaths:(NSArray *)indexPaths withRowAnimation:(UITableViewRowAnimation)animation
{
[_dataController reloadRowsAtIndexPaths:indexPaths];
[_dataController reloadRowsAtIndexPaths:indexPaths withAnimationOption:animation];
}
- (void)moveRowAtIndexPath:(NSIndexPath *)indexPath toIndexPath:(NSIndexPath *)newIndexPath
@@ -341,6 +341,16 @@ static BOOL _isInterceptedSelector(SEL sel)
#pragma mark -
#pragma mark ASRangeControllerDelegate.
- (void)rangeControllerBeginUpdates:(ASRangeController *)rangeController {
ASDisplayNodeAssertMainThread();
[super beginUpdates];
}
- (void)rangeControllerEndUpdates:(ASRangeController *)rangeController {
ASDisplayNodeAssertMainThread();
[super endUpdates];
}
- (NSArray *)rangeControllerVisibleNodeIndexPaths:(ASRangeController *)rangeController
{
ASDisplayNodeAssertMainThread();
@@ -358,40 +368,40 @@ static BOOL _isInterceptedSelector(SEL sel)
return self.bounds.size;
}
- (void)rangeController:(ASRangeController *)rangeController didInsertNodesAtIndexPaths:(NSArray *)indexPaths
- (void)rangeController:(ASRangeController *)rangeController didInsertNodesAtIndexPaths:(NSArray *)indexPaths withAnimationOption:(ASDataControllerAnimationOptions)animationOption
{
ASDisplayNodeAssertMainThread();
[UIView performWithoutAnimation:^{
[super insertRowsAtIndexPaths:indexPaths withRowAnimation:UITableViewRowAnimationNone];
}];
// [UIView performWithoutAnimation:^{
[super insertRowsAtIndexPaths:indexPaths withRowAnimation:(UITableViewRowAnimation)animationOption];
// }];
}
- (void)rangeController:(ASRangeController *)rangeController didDeleteNodesAtIndexPaths:(NSArray *)indexPaths
- (void)rangeController:(ASRangeController *)rangeController didDeleteNodesAtIndexPaths:(NSArray *)indexPaths withAnimationOption:(ASDataControllerAnimationOptions)animationOption
{
ASDisplayNodeAssertMainThread();
[UIView performWithoutAnimation:^{
[super deleteRowsAtIndexPaths:indexPaths withRowAnimation:UITableViewRowAnimationNone];
}];
// [UIView performWithoutAnimation:^{
[super deleteRowsAtIndexPaths:indexPaths withRowAnimation:(UITableViewRowAnimation)animationOption];
// }];
}
- (void)rangeController:(ASRangeController *)rangeController didInsertSectionsAtIndexSet:(NSIndexSet *)indexSet
- (void)rangeController:(ASRangeController *)rangeController didInsertSectionsAtIndexSet:(NSIndexSet *)indexSet withAnimationOption:(ASDataControllerAnimationOptions)animationOption
{
ASDisplayNodeAssertMainThread();
[UIView performWithoutAnimation:^{
[super insertSections:indexSet withRowAnimation:UITableViewRowAnimationNone];
}];
// [UIView performWithoutAnimation:^{
[super insertSections:indexSet withRowAnimation:(UITableViewRowAnimation)animationOption];
// }];
}
- (void)rangeController:(ASRangeController *)rangeController didDeleteSectionsAtIndexSet:(NSIndexSet *)indexSet
- (void)rangeController:(ASRangeController *)rangeController didDeleteSectionsAtIndexSet:(NSIndexSet *)indexSet withAnimationOption:(ASDataControllerAnimationOptions)animationOption
{
ASDisplayNodeAssertMainThread();
[UIView performWithoutAnimation:^{
[super deleteSections:indexSet withRowAnimation:UITableViewRowAnimationNone];
}];
// [UIView performWithoutAnimation:^{
[super deleteSections:indexSet withRowAnimation:(UITableViewRowAnimation)animationOption];
// }];
}
#pragma mark - ASDataControllerDelegate