mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2026-01-29 23:40:06 +00:00
Merge pull request #405 from eanagel/reloadData-completion
Add (optional) completion handler for ASTableView and AsCollectionView reloadData
This commit is contained in:
@@ -70,6 +70,15 @@
|
||||
*/
|
||||
@property (nonatomic, assign) CGFloat leadingScreensForBatching;
|
||||
|
||||
/**
|
||||
* Reload everything from scratch, destroying the working range and all cached nodes.
|
||||
*
|
||||
* @param completion block to run on completion of asynchronous loading or nil. If supplied, the block is run on
|
||||
* the main thread.
|
||||
* @warning This method is substantially more expensive than UICollectionView's version.
|
||||
*/
|
||||
- (void)reloadDataWithCompletion:(void (^)())completion;
|
||||
|
||||
/**
|
||||
* Reload everything from scratch, destroying the working range and all cached nodes.
|
||||
*
|
||||
|
||||
@@ -162,13 +162,18 @@ static BOOL _isInterceptedSelector(SEL sel)
|
||||
#pragma mark -
|
||||
#pragma mark Overrides.
|
||||
|
||||
- (void)reloadData
|
||||
- (void)reloadDataWithCompletion:(void (^)())completion
|
||||
{
|
||||
ASDisplayNodeAssert(self.asyncDelegate, @"ASCollectionView's asyncDelegate property must be set.");
|
||||
ASDisplayNodePerformBlockOnMainThread(^{
|
||||
[super reloadData];
|
||||
});
|
||||
[_dataController reloadDataWithAnimationOption:kASCollectionViewAnimationNone];
|
||||
[_dataController reloadDataWithAnimationOption:kASCollectionViewAnimationNone completion:completion];
|
||||
}
|
||||
|
||||
- (void)reloadData
|
||||
{
|
||||
[self reloadDataWithCompletion:nil];
|
||||
}
|
||||
|
||||
- (void)setDataSource:(id<UICollectionViewDataSource>)dataSource
|
||||
|
||||
@@ -70,6 +70,15 @@
|
||||
*/
|
||||
@property (nonatomic, assign) CGFloat leadingScreensForBatching;
|
||||
|
||||
/**
|
||||
* Reload everything from scratch, destroying the working range and all cached nodes.
|
||||
*
|
||||
* @param completion block to run on completion of asynchronous loading or nil. If supplied, the block is run on
|
||||
* the main thread.
|
||||
* @warning This method is substantially more expensive than UITableView's version.
|
||||
*/
|
||||
-(void)reloadDataWithCompletion:(void (^)())completion;
|
||||
|
||||
/**
|
||||
* Reload everything from scratch, destroying the working range and all cached nodes.
|
||||
*
|
||||
|
||||
@@ -205,13 +205,18 @@ static BOOL _isInterceptedSelector(SEL sel)
|
||||
}
|
||||
}
|
||||
|
||||
- (void)reloadData
|
||||
- (void)reloadDataWithCompletion:(void (^)())completion
|
||||
{
|
||||
ASDisplayNodeAssert(self.asyncDelegate, @"ASTableView's asyncDelegate property must be set.");
|
||||
ASDisplayNodePerformBlockOnMainThread(^{
|
||||
[super reloadData];
|
||||
});
|
||||
[_dataController reloadDataWithAnimationOption:UITableViewRowAnimationNone];
|
||||
[_dataController reloadDataWithAnimationOption:UITableViewRowAnimationNone completion:completion];
|
||||
}
|
||||
|
||||
- (void)reloadData
|
||||
{
|
||||
[self reloadDataWithCompletion:nil];
|
||||
}
|
||||
|
||||
- (void)setTuningParameters:(ASRangeTuningParameters)tuningParameters forRangeType:(ASLayoutRangeType)rangeType
|
||||
|
||||
@@ -155,7 +155,7 @@ typedef NSUInteger ASDataControllerAnimationOptions;
|
||||
|
||||
- (void)moveRowAtIndexPath:(NSIndexPath *)indexPath toIndexPath:(NSIndexPath *)newIndexPath withAnimationOption:(ASDataControllerAnimationOptions)animationOption;;
|
||||
|
||||
- (void)reloadDataWithAnimationOption:(ASDataControllerAnimationOptions)animationOption;;
|
||||
- (void)reloadDataWithAnimationOption:(ASDataControllerAnimationOptions)animationOption completion:(void (^)())completion;
|
||||
|
||||
/** @name Data Querying */
|
||||
|
||||
|
||||
@@ -437,7 +437,7 @@ static void *kASSizingQueueContext = &kASSizingQueueContext;
|
||||
});
|
||||
}
|
||||
|
||||
- (void)reloadDataWithAnimationOption:(ASDataControllerAnimationOptions)animationOption
|
||||
- (void)reloadDataWithAnimationOption:(ASDataControllerAnimationOptions)animationOption completion:(void (^)())completion
|
||||
{
|
||||
[self performDataFetchingWithBlock:^{
|
||||
// Fetching data in calling thread
|
||||
@@ -478,6 +478,10 @@ static void *kASSizingQueueContext = &kASSizingQueueContext;
|
||||
}];
|
||||
|
||||
[self _batchInsertNodes:updatedNodes atIndexPaths:updatedIndexPaths withAnimationOptions:animationOption];
|
||||
|
||||
if (completion) {
|
||||
dispatch_async(dispatch_get_main_queue(), completion);
|
||||
}
|
||||
});
|
||||
}];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user