mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-09-12 23:28:25 +00:00
Revert commit 83aaa46, thus bring 2e4d716 back
This commit is contained in:
parent
b3239b6d36
commit
209425c22c
@ -250,7 +250,7 @@ static NSString * const kCellReuseIdentifier = @"_ASCollectionViewCell";
|
|||||||
_superIsPendingDataLoad = YES;
|
_superIsPendingDataLoad = YES;
|
||||||
[super reloadData];
|
[super reloadData];
|
||||||
});
|
});
|
||||||
[_dataController reloadDataWithAnimationOptions:kASCollectionViewAnimationNone completion:completion];
|
[_dataController reloadDataWithCompletion:completion];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)reloadData
|
- (void)reloadData
|
||||||
@ -262,7 +262,7 @@ static NSString * const kCellReuseIdentifier = @"_ASCollectionViewCell";
|
|||||||
{
|
{
|
||||||
ASDisplayNodeAssertMainThread();
|
ASDisplayNodeAssertMainThread();
|
||||||
_superIsPendingDataLoad = YES;
|
_superIsPendingDataLoad = YES;
|
||||||
[_dataController reloadDataImmediatelyWithAnimationOptions:kASCollectionViewAnimationNone];
|
[_dataController reloadDataImmediately];
|
||||||
[super reloadData];
|
[super reloadData];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -938,6 +938,25 @@ static NSString * const kCellReuseIdentifier = @"_ASCollectionViewCell";
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)rangeControllerDidReloadData:(ASRangeController *)rangeController
|
||||||
|
{
|
||||||
|
ASDisplayNodeAssertMainThread();
|
||||||
|
|
||||||
|
if (!self.asyncDataSource || _superIsPendingDataLoad) {
|
||||||
|
return; // if the asyncDataSource has become invalid while we are processing, ignore this request to avoid crashes
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_performingBatchUpdates) {
|
||||||
|
[_batchUpdateBlocks addObject:^{
|
||||||
|
[super reloadData];
|
||||||
|
}];
|
||||||
|
} else {
|
||||||
|
[UIView performWithoutAnimation:^{
|
||||||
|
[super reloadData];
|
||||||
|
}];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#pragma mark - ASCellNodeDelegate
|
#pragma mark - ASCellNodeDelegate
|
||||||
|
|
||||||
- (void)nodeDidRelayout:(ASCellNode *)node sizeChanged:(BOOL)sizeChanged
|
- (void)nodeDidRelayout:(ASCellNode *)node sizeChanged:(BOOL)sizeChanged
|
||||||
|
@ -298,10 +298,7 @@ static NSString * const kCellReuseIdentifier = @"_ASTableViewCell";
|
|||||||
|
|
||||||
- (void)reloadDataWithCompletion:(void (^)())completion
|
- (void)reloadDataWithCompletion:(void (^)())completion
|
||||||
{
|
{
|
||||||
ASPerformBlockOnMainThread(^{
|
[_dataController reloadDataWithCompletion:completion];
|
||||||
[super reloadData];
|
|
||||||
});
|
|
||||||
[_dataController reloadDataWithAnimationOptions:UITableViewRowAnimationNone completion:completion];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)reloadData
|
- (void)reloadData
|
||||||
@ -312,8 +309,7 @@ static NSString * const kCellReuseIdentifier = @"_ASTableViewCell";
|
|||||||
- (void)reloadDataImmediately
|
- (void)reloadDataImmediately
|
||||||
{
|
{
|
||||||
ASDisplayNodeAssertMainThread();
|
ASDisplayNodeAssertMainThread();
|
||||||
[_dataController reloadDataImmediatelyWithAnimationOptions:UITableViewRowAnimationNone];
|
[_dataController reloadDataImmediately];
|
||||||
[super reloadData];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setTuningParameters:(ASRangeTuningParameters)tuningParameters forRangeType:(ASLayoutRangeType)rangeType
|
- (void)setTuningParameters:(ASRangeTuningParameters)tuningParameters forRangeType:(ASLayoutRangeType)rangeType
|
||||||
@ -845,6 +841,18 @@ static NSString * const kCellReuseIdentifier = @"_ASTableViewCell";
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)rangeControllerDidReloadData:(ASRangeController *)rangeController
|
||||||
|
{
|
||||||
|
ASDisplayNodeAssertMainThread();
|
||||||
|
LOG(@"UITableView reloadData");
|
||||||
|
|
||||||
|
if (!self.asyncDataSource) {
|
||||||
|
return; // if the asyncDataSource has become invalid while we are processing, ignore this request to avoid crashes
|
||||||
|
}
|
||||||
|
|
||||||
|
[super reloadData];
|
||||||
|
}
|
||||||
|
|
||||||
#pragma mark - ASDataControllerDelegate
|
#pragma mark - ASDataControllerDelegate
|
||||||
|
|
||||||
- (ASCellNode *)dataController:(ASDataController *)dataController nodeAtIndexPath:(NSIndexPath *)indexPath
|
- (ASCellNode *)dataController:(ASDataController *)dataController nodeAtIndexPath:(NSIndexPath *)indexPath
|
||||||
|
@ -94,6 +94,11 @@ FOUNDATION_EXPORT NSString * const ASDataControllerRowNodeKind;
|
|||||||
*/
|
*/
|
||||||
- (void)dataController:(ASDataController *)dataController didDeleteSectionsAtIndexSet:(NSIndexSet *)indexSet withAnimationOptions:(ASDataControllerAnimationOptions)animationOptions;
|
- (void)dataController:(ASDataController *)dataController didDeleteSectionsAtIndexSet:(NSIndexSet *)indexSet withAnimationOptions:(ASDataControllerAnimationOptions)animationOptions;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Called for data reload.
|
||||||
|
*/
|
||||||
|
- (void)dataControllerDidReloadData:(ASDataController *)dataController;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -170,9 +175,9 @@ FOUNDATION_EXPORT NSString * const ASDataControllerRowNodeKind;
|
|||||||
|
|
||||||
- (void)moveRowAtIndexPath:(NSIndexPath *)indexPath toIndexPath:(NSIndexPath *)newIndexPath withAnimationOptions:(ASDataControllerAnimationOptions)animationOptions;
|
- (void)moveRowAtIndexPath:(NSIndexPath *)indexPath toIndexPath:(NSIndexPath *)newIndexPath withAnimationOptions:(ASDataControllerAnimationOptions)animationOptions;
|
||||||
|
|
||||||
- (void)reloadDataWithAnimationOptions:(ASDataControllerAnimationOptions)animationOptions completion:(void (^ _Nullable)())completion;
|
- (void)reloadDataWithCompletion:(void (^ _Nullable)())completion;
|
||||||
|
|
||||||
- (void)reloadDataImmediatelyWithAnimationOptions:(ASDataControllerAnimationOptions)animationOptions;
|
- (void)reloadDataImmediately;
|
||||||
|
|
||||||
/** @name Data Querying */
|
/** @name Data Querying */
|
||||||
|
|
||||||
|
@ -43,6 +43,7 @@ static void *kASSizingQueueContext = &kASSizingQueueContext;
|
|||||||
BOOL _delegateDidDeleteNodes;
|
BOOL _delegateDidDeleteNodes;
|
||||||
BOOL _delegateDidInsertSections;
|
BOOL _delegateDidInsertSections;
|
||||||
BOOL _delegateDidDeleteSections;
|
BOOL _delegateDidDeleteSections;
|
||||||
|
BOOL _delegateDidReloadData;
|
||||||
}
|
}
|
||||||
|
|
||||||
@property (atomic, assign) NSUInteger batchUpdateCounter;
|
@property (atomic, assign) NSUInteger batchUpdateCounter;
|
||||||
@ -92,6 +93,7 @@ static void *kASSizingQueueContext = &kASSizingQueueContext;
|
|||||||
_delegateDidDeleteNodes = [_delegate respondsToSelector:@selector(dataController:didDeleteNodes:atIndexPaths:withAnimationOptions:)];
|
_delegateDidDeleteNodes = [_delegate respondsToSelector:@selector(dataController:didDeleteNodes:atIndexPaths:withAnimationOptions:)];
|
||||||
_delegateDidInsertSections = [_delegate respondsToSelector:@selector(dataController:didInsertSections:atIndexSet:withAnimationOptions:)];
|
_delegateDidInsertSections = [_delegate respondsToSelector:@selector(dataController:didInsertSections:atIndexSet:withAnimationOptions:)];
|
||||||
_delegateDidDeleteSections = [_delegate respondsToSelector:@selector(dataController:didDeleteSectionsAtIndexSet:withAnimationOptions:)];
|
_delegateDidDeleteSections = [_delegate respondsToSelector:@selector(dataController:didDeleteSectionsAtIndexSet:withAnimationOptions:)];
|
||||||
|
_delegateDidReloadData = [_delegate respondsToSelector:@selector(dataControllerDidReloadData:)];
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (NSUInteger)parallelProcessorCount
|
+ (NSUInteger)parallelProcessorCount
|
||||||
@ -143,14 +145,30 @@ static void *kASSizingQueueContext = &kASSizingQueueContext;
|
|||||||
node.frame = CGRectMake(0.0f, 0.0f, node.calculatedSize.width, node.calculatedSize.height);
|
node.frame = CGRectMake(0.0f, 0.0f, node.calculatedSize.width, node.calculatedSize.height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Measures and defines the layout for each node in optimized batches on an editing queue, inserting the results into the backing store.
|
||||||
|
*/
|
||||||
|
- (void)_batchLayoutNodes:(NSArray *)nodes atIndexPaths:(NSArray *)indexPaths
|
||||||
|
{
|
||||||
|
[self _batchLayoutNodes:nodes atIndexPaths:indexPaths andNotifyDelegate:NO withAnimationOptions:0];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Measures and defines the layout for each node in optimized batches on an editing queue, inserting the results into the backing store.
|
* Measures and defines the layout for each node in optimized batches on an editing queue, inserting the results into the backing store.
|
||||||
*/
|
*/
|
||||||
- (void)_batchLayoutNodes:(NSArray *)nodes atIndexPaths:(NSArray *)indexPaths withAnimationOptions:(ASDataControllerAnimationOptions)animationOptions
|
- (void)_batchLayoutNodes:(NSArray *)nodes atIndexPaths:(NSArray *)indexPaths withAnimationOptions:(ASDataControllerAnimationOptions)animationOptions
|
||||||
|
{
|
||||||
|
[self _batchLayoutNodes:nodes atIndexPaths:indexPaths andNotifyDelegate:YES withAnimationOptions:animationOptions];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Measures and defines the layout for each node in optimized batches on an editing queue, inserting the results into the backing store.
|
||||||
|
*/
|
||||||
|
- (void)_batchLayoutNodes:(NSArray *)nodes atIndexPaths:(NSArray *)indexPaths andNotifyDelegate:(BOOL)shouldNotifyDelegate withAnimationOptions:(ASDataControllerAnimationOptions)animationOptions
|
||||||
{
|
{
|
||||||
[self batchLayoutNodes:nodes ofKind:ASDataControllerRowNodeKind atIndexPaths:indexPaths completion:^(NSArray *nodes, NSArray *indexPaths) {
|
[self batchLayoutNodes:nodes ofKind:ASDataControllerRowNodeKind atIndexPaths:indexPaths completion:^(NSArray *nodes, NSArray *indexPaths) {
|
||||||
// Insert finished nodes into data storage
|
// Insert finished nodes into data storage
|
||||||
[self _insertNodes:nodes atIndexPaths:indexPaths withAnimationOptions:animationOptions];
|
[self _insertNodes:nodes atIndexPaths:indexPaths andNotifyDelegate:shouldNotifyDelegate withAnimationOptions:animationOptions];
|
||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -240,6 +258,14 @@ static void *kASSizingQueueContext = &kASSizingQueueContext;
|
|||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)deleteAllNodesOfKind:(NSString *)kind
|
||||||
|
{
|
||||||
|
[_editingNodes[kind] removeAllObjects];
|
||||||
|
[_mainSerialQueue performBlockOnMainThread:^{
|
||||||
|
[_completedNodes[kind] removeAllObjects];
|
||||||
|
}];
|
||||||
|
}
|
||||||
|
|
||||||
- (void)insertSections:(NSMutableArray *)sections ofKind:(NSString *)kind atIndexSet:(NSIndexSet *)indexSet completion:(void (^)(NSArray *sections, NSIndexSet *indexSet))completionBlock
|
- (void)insertSections:(NSMutableArray *)sections ofKind:(NSString *)kind atIndexSet:(NSIndexSet *)indexSet completion:(void (^)(NSArray *sections, NSIndexSet *indexSet))completionBlock
|
||||||
{
|
{
|
||||||
if (indexSet.count == 0)
|
if (indexSet.count == 0)
|
||||||
@ -277,6 +303,17 @@ static void *kASSizingQueueContext = &kASSizingQueueContext;
|
|||||||
|
|
||||||
#pragma mark - Internal Data Querying + Editing
|
#pragma mark - Internal Data Querying + Editing
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Inserts the specified nodes into the given index paths and doesn't notify the delegate of newly inserted nodes.
|
||||||
|
*
|
||||||
|
* @discussion Nodes are first inserted into the editing store, then the completed store is replaced by a deep copy
|
||||||
|
* of the editing nodes.
|
||||||
|
*/
|
||||||
|
- (void)_insertNodes:(NSArray *)nodes atIndexPaths:(NSArray *)indexPaths
|
||||||
|
{
|
||||||
|
[self _insertNodes:nodes atIndexPaths:indexPaths andNotifyDelegate:NO withAnimationOptions:0];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Inserts the specified nodes into the given index paths and notifies the delegate of newly inserted nodes.
|
* Inserts the specified nodes into the given index paths and notifies the delegate of newly inserted nodes.
|
||||||
*
|
*
|
||||||
@ -285,10 +322,26 @@ static void *kASSizingQueueContext = &kASSizingQueueContext;
|
|||||||
*/
|
*/
|
||||||
- (void)_insertNodes:(NSArray *)nodes atIndexPaths:(NSArray *)indexPaths withAnimationOptions:(ASDataControllerAnimationOptions)animationOptions
|
- (void)_insertNodes:(NSArray *)nodes atIndexPaths:(NSArray *)indexPaths withAnimationOptions:(ASDataControllerAnimationOptions)animationOptions
|
||||||
{
|
{
|
||||||
[self insertNodes:nodes ofKind:ASDataControllerRowNodeKind atIndexPaths:indexPaths completion:^(NSArray *nodes, NSArray *indexPaths) {
|
[self _insertNodes:nodes atIndexPaths:indexPaths andNotifyDelegate:YES withAnimationOptions:animationOptions];
|
||||||
if (_delegateDidInsertNodes)
|
}
|
||||||
[_delegate dataController:self didInsertNodes:nodes atIndexPaths:indexPaths withAnimationOptions:animationOptions];
|
|
||||||
}];
|
/**
|
||||||
|
* Inserts the specified nodes into the given index paths and notifies the delegate of newly inserted nodes.
|
||||||
|
*
|
||||||
|
* @discussion Nodes are first inserted into the editing store, then the completed store is replaced by a deep copy
|
||||||
|
* of the editing nodes. The delegate is invoked on the main thread.
|
||||||
|
*/
|
||||||
|
- (void)_insertNodes:(NSArray *)nodes atIndexPaths:(NSArray *)indexPaths andNotifyDelegate:(BOOL)shouldNotifyDelegate withAnimationOptions:(ASDataControllerAnimationOptions)animationOptions
|
||||||
|
{
|
||||||
|
void (^completionBlock)(NSArray *nodes, NSArray *indexPaths) = nil;
|
||||||
|
if (shouldNotifyDelegate) {
|
||||||
|
completionBlock = ^(NSArray *nodes, NSArray *indexPaths) {
|
||||||
|
if (_delegateDidInsertNodes)
|
||||||
|
[_delegate dataController:self didInsertNodes:nodes atIndexPaths:indexPaths withAnimationOptions:animationOptions];
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
[self insertNodes:nodes ofKind:ASDataControllerRowNodeKind atIndexPaths:indexPaths completion:completionBlock];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -305,18 +358,46 @@ static void *kASSizingQueueContext = &kASSizingQueueContext;
|
|||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Inserts sections, represented as arrays, into the backing store at the given indicies and doesn't notify the delegate.
|
||||||
|
*
|
||||||
|
* @discussion The section arrays are inserted into the editing store, then a deep copy of the sections are inserted
|
||||||
|
* in the completed store on the main thread.
|
||||||
|
*/
|
||||||
|
- (void)_insertSections:(NSMutableArray *)sections atIndexSet:(NSIndexSet *)indexSet
|
||||||
|
{
|
||||||
|
[self _insertSections:sections atIndexSet:indexSet andNotifyDelegate:NO withAnimationOptions:0];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Inserts sections, represented as arrays, into the backing store at the given indicies and doesn't notify the delegate.
|
||||||
|
*
|
||||||
|
* @discussion The section arrays are inserted into the editing store, then a deep copy of the sections are inserted
|
||||||
|
* in the completed store on the main thread.
|
||||||
|
*/
|
||||||
|
- (void)_insertSections:(NSMutableArray *)sections atIndexSet:(NSIndexSet *)indexSet withAnimationOptions:(ASDataControllerAnimationOptions)animationOptions
|
||||||
|
{
|
||||||
|
[self _insertSections:sections atIndexSet:indexSet andNotifyDelegate:YES withAnimationOptions:animationOptions];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Inserts sections, represented as arrays, into the backing store at the given indicies and notifies the delegate.
|
* Inserts sections, represented as arrays, into the backing store at the given indicies and notifies the delegate.
|
||||||
*
|
*
|
||||||
* @discussion The section arrays are inserted into the editing store, then a deep copy of the sections are inserted
|
* @discussion The section arrays are inserted into the editing store, then a deep copy of the sections are inserted
|
||||||
* in the completed store on the main thread. The delegate is invoked on the main thread.
|
* in the completed store on the main thread. The delegate is invoked on the main thread.
|
||||||
*/
|
*/
|
||||||
- (void)_insertSections:(NSMutableArray *)sections atIndexSet:(NSIndexSet *)indexSet withAnimationOptions:(ASDataControllerAnimationOptions)animationOptions
|
- (void)_insertSections:(NSMutableArray *)sections atIndexSet:(NSIndexSet *)indexSet andNotifyDelegate:(BOOL)shouldNotifyDelegate withAnimationOptions:(ASDataControllerAnimationOptions)animationOptions
|
||||||
{
|
{
|
||||||
[self insertSections:sections ofKind:ASDataControllerRowNodeKind atIndexSet:indexSet completion:^(NSArray *sections, NSIndexSet *indexSet) {
|
|
||||||
if (_delegateDidInsertSections)
|
void (^completionBlock)(NSArray *sections, NSIndexSet *indexSet) = nil;
|
||||||
[_delegate dataController:self didInsertSections:sections atIndexSet:indexSet withAnimationOptions:animationOptions];
|
if (shouldNotifyDelegate) {
|
||||||
}];
|
completionBlock = ^(NSArray *sections, NSIndexSet *indexSet) {
|
||||||
|
if (_delegateDidInsertSections)
|
||||||
|
[_delegate dataController:self didInsertSections:sections atIndexSet:indexSet withAnimationOptions:animationOptions];
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
[self insertSections:sections ofKind:ASDataControllerRowNodeKind atIndexSet:indexSet completion:completionBlock];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -361,17 +442,17 @@ static void *kASSizingQueueContext = &kASSizingQueueContext;
|
|||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)reloadDataWithAnimationOptions:(ASDataControllerAnimationOptions)animationOptions completion:(void (^)())completion
|
- (void)reloadDataWithCompletion:(void (^)())completion
|
||||||
{
|
{
|
||||||
[self _reloadDataWithAnimationOptions:animationOptions synchronously:NO completion:completion];
|
[self _reloadDataSynchronously:NO completion:completion];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)reloadDataImmediatelyWithAnimationOptions:(ASDataControllerAnimationOptions)animationOptions
|
- (void)reloadDataImmediately
|
||||||
{
|
{
|
||||||
[self _reloadDataWithAnimationOptions:animationOptions synchronously:YES completion:nil];
|
[self _reloadDataSynchronously:YES completion:nil];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)_reloadDataWithAnimationOptions:(ASDataControllerAnimationOptions)animationOptions synchronously:(BOOL)synchronously completion:(void (^)())completion
|
- (void)_reloadDataSynchronously:(BOOL)synchronously completion:(void (^)())completion
|
||||||
{
|
{
|
||||||
[self performEditCommandWithBlock:^{
|
[self performEditCommandWithBlock:^{
|
||||||
ASDisplayNodeAssertMainThread();
|
ASDisplayNodeAssertMainThread();
|
||||||
@ -393,12 +474,7 @@ static void *kASSizingQueueContext = &kASSizingQueueContext;
|
|||||||
LOG(@"Edit Transaction - reloadData");
|
LOG(@"Edit Transaction - reloadData");
|
||||||
|
|
||||||
// Remove everything that existed before the reload, now that we're ready to insert replacements
|
// Remove everything that existed before the reload, now that we're ready to insert replacements
|
||||||
NSArray *indexPaths = ASIndexPathsForMultidimensionalArray(_editingNodes[ASDataControllerRowNodeKind]);
|
[self deleteAllNodesOfKind:ASDataControllerRowNodeKind];
|
||||||
[self _deleteNodesAtIndexPaths:indexPaths withAnimationOptions:animationOptions];
|
|
||||||
|
|
||||||
NSMutableArray *editingNodes = _editingNodes[ASDataControllerRowNodeKind];
|
|
||||||
NSMutableIndexSet *indexSet = [[NSMutableIndexSet alloc] initWithIndexesInRange:NSMakeRange(0, editingNodes.count)];
|
|
||||||
[self _deleteSectionsAtIndexSet:indexSet withAnimationOptions:animationOptions];
|
|
||||||
|
|
||||||
[self willReloadData];
|
[self willReloadData];
|
||||||
|
|
||||||
@ -408,12 +484,19 @@ static void *kASSizingQueueContext = &kASSizingQueueContext;
|
|||||||
[sections addObject:[[NSMutableArray alloc] init]];
|
[sections addObject:[[NSMutableArray alloc] init]];
|
||||||
}
|
}
|
||||||
|
|
||||||
[self _insertSections:sections atIndexSet:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, sectionCount)] withAnimationOptions:animationOptions];
|
[self _insertSections:sections atIndexSet:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, sectionCount)]];
|
||||||
|
|
||||||
[self _batchLayoutNodes:updatedNodes atIndexPaths:updatedIndexPaths withAnimationOptions:animationOptions];
|
[self _batchLayoutNodes:updatedNodes atIndexPaths:updatedIndexPaths];
|
||||||
|
|
||||||
if (completion) {
|
if (_delegateDidReloadData || completion) {
|
||||||
dispatch_async(dispatch_get_main_queue(), completion);
|
[_mainSerialQueue performBlockOnMainThread:^{
|
||||||
|
if (_delegateDidReloadData) {
|
||||||
|
[_delegate dataControllerDidReloadData:self];
|
||||||
|
}
|
||||||
|
if (completion) {
|
||||||
|
completion();
|
||||||
|
}
|
||||||
|
}];
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -190,6 +190,13 @@ NS_ASSUME_NONNULL_BEGIN
|
|||||||
*/
|
*/
|
||||||
- (void)rangeController:(ASRangeController *)rangeController didDeleteSectionsAtIndexSet:(NSIndexSet *)indexSet withAnimationOptions:(ASDataControllerAnimationOptions)animationOptions;
|
- (void)rangeController:(ASRangeController *)rangeController didDeleteSectionsAtIndexSet:(NSIndexSet *)indexSet withAnimationOptions:(ASDataControllerAnimationOptions)animationOptions;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called for data reload.
|
||||||
|
*
|
||||||
|
* @param rangeController Sender.
|
||||||
|
*/
|
||||||
|
- (void)rangeControllerDidReloadData:(ASRangeController *)rangeController;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
NS_ASSUME_NONNULL_END
|
NS_ASSUME_NONNULL_END
|
@ -276,4 +276,17 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)dataControllerDidReloadData:(ASDataController *)dataController
|
||||||
|
{
|
||||||
|
ASPerformBlockOnMainThread(^{
|
||||||
|
_rangeIsValid = NO;
|
||||||
|
|
||||||
|
// When reload data we need to make sure that _rangeTypeIndexPaths is cleared as well,
|
||||||
|
// otherwise _updateVisibleNodeIndexPaths may try to retrieve nodes from dataSource that aren't there anymore
|
||||||
|
[_rangeTypeIndexPaths removeAllObjects];
|
||||||
|
|
||||||
|
[_delegate rangeControllerDidReloadData:self];
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
@ -288,4 +288,12 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)dataControllerDidReloadData:(ASDataController *)dataController
|
||||||
|
{
|
||||||
|
ASPerformBlockOnMainThread(^{
|
||||||
|
_rangeIsValid = NO;
|
||||||
|
[_delegate rangeControllerDidReloadData:self];
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user