mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-24 07:05:35 +00:00
Remove bachUpdate and begin/endUpdate
This commit is contained in:
@@ -348,11 +348,9 @@ static BOOL _isInterceptedSelector(SEL sel)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark ASRangeControllerDelegate.
|
||||
|
||||
|
||||
- (NSArray *)rangeControllerVisibleNodeIndexPaths:(ASRangeController *)rangeController
|
||||
{
|
||||
ASDisplayNodeAssertMainThread();
|
||||
@@ -372,36 +370,28 @@ static BOOL _isInterceptedSelector(SEL sel)
|
||||
- (void)rangeController:(ASRangeController *)rangeController didInsertNodesAtIndexPaths:(NSArray *)indexPaths {
|
||||
ASDisplayNodeAssertMainThread();
|
||||
[UIView performWithoutAnimation:^{
|
||||
[self performBatchUpdates:^{
|
||||
[super insertItemsAtIndexPaths:indexPaths];
|
||||
} completion:nil];
|
||||
[super insertItemsAtIndexPaths:indexPaths];
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)rangeController:(ASRangeController *)rangeController didDeleteNodesAtIndexPaths:(NSArray *)indexPaths {
|
||||
ASDisplayNodeAssertMainThread();
|
||||
[UIView performWithoutAnimation:^{
|
||||
[self performBatchUpdates:^{
|
||||
[super deleteItemsAtIndexPaths:indexPaths];
|
||||
} completion:nil];
|
||||
[super deleteItemsAtIndexPaths:indexPaths];
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)rangeController:(ASRangeController *)rangeController didInsertSectionsAtIndexSet:(NSIndexSet *)indexSet {
|
||||
ASDisplayNodeAssertMainThread();
|
||||
[UIView performWithoutAnimation:^{
|
||||
[self performBatchUpdates:^{
|
||||
[super insertSections:indexSet];
|
||||
} completion:nil];
|
||||
[super insertSections:indexSet];
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)rangeController:(ASRangeController *)rangeController didDeleteSectionsAtIndexSet:(NSIndexSet *)indexSet {
|
||||
ASDisplayNodeAssertMainThread();
|
||||
[UIView performWithoutAnimation:^{
|
||||
[self performBatchUpdates:^{
|
||||
[super deleteSections:indexSet];
|
||||
} completion:nil];
|
||||
[super deleteSections:indexSet];
|
||||
}];
|
||||
}
|
||||
|
||||
|
||||
@@ -361,9 +361,7 @@ static BOOL _isInterceptedSelector(SEL sel)
|
||||
ASDisplayNodeAssertMainThread();
|
||||
|
||||
[UIView performWithoutAnimation:^{
|
||||
[super beginUpdates];
|
||||
[super insertRowsAtIndexPaths:indexPaths withRowAnimation:UITableViewRowAnimationNone];
|
||||
[super endUpdates];
|
||||
}];
|
||||
}
|
||||
|
||||
@@ -371,9 +369,7 @@ static BOOL _isInterceptedSelector(SEL sel)
|
||||
ASDisplayNodeAssertMainThread();
|
||||
|
||||
[UIView performWithoutAnimation:^{
|
||||
[super beginUpdates];
|
||||
[super deleteRowsAtIndexPaths:indexPaths withRowAnimation:UITableViewRowAnimationNone];
|
||||
[super endUpdates];
|
||||
}];
|
||||
}
|
||||
|
||||
@@ -381,9 +377,7 @@ static BOOL _isInterceptedSelector(SEL sel)
|
||||
ASDisplayNodeAssertMainThread();
|
||||
|
||||
[UIView performWithoutAnimation:^{
|
||||
[super beginUpdates];
|
||||
[super insertSections:indexSet withRowAnimation:UITableViewRowAnimationNone];
|
||||
[super endUpdates];
|
||||
}];
|
||||
}
|
||||
|
||||
@@ -391,9 +385,7 @@ static BOOL _isInterceptedSelector(SEL sel)
|
||||
ASDisplayNodeAssertMainThread();
|
||||
|
||||
[UIView performWithoutAnimation:^{
|
||||
[super beginUpdates];
|
||||
[super deleteSections:indexSet withRowAnimation:UITableViewRowAnimationNone];
|
||||
[super endUpdates];
|
||||
}];
|
||||
}
|
||||
|
||||
|
||||
@@ -95,4 +95,26 @@
|
||||
*/
|
||||
- (void)rangeController:(ASRangeController *)rangeController didDeleteSectionsAtIndexSet:(NSIndexSet *)indexSet;
|
||||
|
||||
@optional
|
||||
|
||||
/**
|
||||
* Called before nodes insertion.
|
||||
*/
|
||||
- (void)rangeController:(ASRangeController *)rangeController willInsertNodesAtIndexPaths:(NSArray *)indexPaths;
|
||||
|
||||
/**
|
||||
* Called before nodes deletion.
|
||||
*/
|
||||
- (void)rangeController:(ASRangeController *)rangeController willDeleteNodesAtIndexPaths:(NSArray *)indexPaths;
|
||||
|
||||
/**
|
||||
* Called before section insertion.
|
||||
*/
|
||||
- (void)rangeController:(ASRangeController *)rangeController willInsertSectionsAtIndexSet:(NSIndexSet *)indexSet;
|
||||
|
||||
/**
|
||||
* Called before section deletion.
|
||||
*/
|
||||
- (void)rangeController:(ASRangeController *)rangeController willDeleteSectionsAtIndexSet:(NSIndexSet *)indexSet;
|
||||
|
||||
@end
|
||||
|
||||
@@ -213,18 +213,12 @@
|
||||
|
||||
#pragma mark - ASDataControllerDelegete
|
||||
|
||||
/**
|
||||
* Dispatch to main thread for updating ranges.
|
||||
* We are considering to move it to background queue if we could call recursive display in background thread.
|
||||
*/
|
||||
- (void)updateOnMainThreadWithBlock:(dispatch_block_t)block {
|
||||
if ([NSThread isMainThread]) {
|
||||
block();
|
||||
} else {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
block();
|
||||
});
|
||||
}
|
||||
- (void)dataController:(ASDataController *)dataController willInsertNodes:(NSArray *)nodes atIndexPaths:(NSArray *)indexPaths {
|
||||
ASDisplayNodePerformBlockOnMainThread(^{
|
||||
if ([_delegate respondsToSelector:@selector(rangeController:willInsertNodesAtIndexPaths:)]) {
|
||||
[_delegate rangeController:self willInsertNodesAtIndexPaths:indexPaths];
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
- (void)dataController:(ASDataController *)dataController didInsertNodes:(NSArray *)nodes atIndexPaths:(NSArray *)indexPaths {
|
||||
@@ -235,19 +229,35 @@
|
||||
[nodeSizes addObject:[NSValue valueWithCGSize:node.calculatedSize]];
|
||||
}];
|
||||
|
||||
[self updateOnMainThreadWithBlock:^{
|
||||
ASDisplayNodePerformBlockOnMainThread(^{
|
||||
[_layoutController insertNodesAtIndexPaths:indexPaths withSizes:nodeSizes];
|
||||
[_delegate rangeController:self didInsertNodesAtIndexPaths:indexPaths];
|
||||
_workingRangeIsValid = NO;
|
||||
}];
|
||||
});
|
||||
}
|
||||
|
||||
- (void)dataController:(ASDataController *)dataController willDeleteNodesAtIndexPaths:(NSArray *)indexPaths {
|
||||
ASDisplayNodePerformBlockOnMainThread(^{
|
||||
if ([_delegate respondsToSelector:@selector(rangeController:willDeleteNodesAtIndexPaths:)]) {
|
||||
[_delegate rangeController:self didDeleteNodesAtIndexPaths:indexPaths];
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
- (void)dataController:(ASDataController *)dataController didDeleteNodesAtIndexPaths:(NSArray *)indexPaths {
|
||||
[self updateOnMainThreadWithBlock:^{
|
||||
ASDisplayNodePerformBlockOnMainThread(^{
|
||||
[_layoutController deleteNodesAtIndexPaths:indexPaths];
|
||||
[_delegate rangeController:self didDeleteNodesAtIndexPaths:indexPaths];
|
||||
_workingRangeIsValid = NO;
|
||||
}];
|
||||
});
|
||||
}
|
||||
|
||||
- (void)dataController:(ASDataController *)dataController willInsertSections:(NSArray *)sections atIndexSet:(NSIndexSet *)indexSet {
|
||||
ASDisplayNodePerformBlockOnMainThread(^{
|
||||
if ([_delegate respondsToSelector:@selector(rangeController:willInsertSectionsAtIndexSet:)]) {
|
||||
[_delegate rangeController:self willInsertSectionsAtIndexSet:indexSet];
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
- (void)dataController:(ASDataController *)dataController didInsertSections:(NSArray *)sections atIndexSet:(NSIndexSet *)indexSet {
|
||||
@@ -263,19 +273,27 @@
|
||||
[sectionNodeSizes addObject:nodeSizes];
|
||||
}];
|
||||
|
||||
[self updateOnMainThreadWithBlock:^{
|
||||
ASDisplayNodePerformBlockOnMainThread(^{
|
||||
[_layoutController insertSections:sectionNodeSizes atIndexSet:indexSet];
|
||||
[_delegate rangeController:self didInsertSectionsAtIndexSet:indexSet];
|
||||
_workingRangeIsValid = NO;
|
||||
}];
|
||||
});
|
||||
}
|
||||
|
||||
- (void)dataController:(ASDataController *)dataController willDeleteSectionsAtIndexSet:(NSIndexSet *)indexSet {
|
||||
ASDisplayNodePerformBlockOnMainThread(^{
|
||||
if ([_delegate respondsToSelector:@selector(rangeController:willDeleteSectionsAtIndexSet:)]) {
|
||||
[_delegate rangeController:self didDeleteSectionsAtIndexSet:indexSet];
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
- (void)dataController:(ASDataController *)dataController didDeleteSectionsAtIndexSet:(NSIndexSet *)indexSet {
|
||||
[self updateOnMainThreadWithBlock:^{
|
||||
ASDisplayNodePerformBlockOnMainThread(^{
|
||||
[_layoutController deleteSectionsAtIndexSet:indexSet];
|
||||
[_delegate rangeController:self didDeleteSectionsAtIndexSet:indexSet];
|
||||
_workingRangeIsValid = NO;
|
||||
}];
|
||||
});
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user