mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-22 14:20:20 +00:00
Move ASTableView & ASCollectionView data fetching to background thread
Conflicts: AsyncDisplayKit/ASCollectionView.mm AsyncDisplayKit/Details/ASDataController.mm Conflicts: AsyncDisplayKit/ASCollectionView.mm AsyncDisplayKit/Details/ASDataController.mm
This commit is contained in:
@@ -112,6 +112,8 @@ static BOOL _isInterceptedSelector(SEL sel)
|
||||
ASRangeController *_rangeController;
|
||||
}
|
||||
|
||||
@property (atomic, assign) BOOL asyncDataSouceLocked;
|
||||
|
||||
@end
|
||||
|
||||
@implementation ASTableView
|
||||
@@ -137,6 +139,8 @@ static BOOL _isInterceptedSelector(SEL sel)
|
||||
_proxyDelegate = [[_ASTableViewProxy alloc] initWithTarget:nil interceptor:self];
|
||||
super.delegate = (id<UITableViewDelegate>)_proxyDelegate;
|
||||
|
||||
_asyncDataSouceLocked = NO;
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
@@ -425,6 +429,28 @@ static BOOL _isInterceptedSelector(SEL sel)
|
||||
return CGSizeMake(self.bounds.size.width, FLT_MAX);
|
||||
}
|
||||
|
||||
- (void)dataControllerLockDataSourceForDataUpdating
|
||||
{
|
||||
ASDisplayNodeAssert(!self.asyncDataSouceLocked, @"The data source has already been locked !");
|
||||
|
||||
self.asyncDataSouceLocked = YES;
|
||||
|
||||
if ([_asyncDataSource respondsToSelector:@selector(tableViewLockDataSourceForDataUpdating:)]) {
|
||||
[_asyncDataSource tableViewLockDataSourceForDataUpdating:self];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)dataControllerUnlockDataSourceForDataUpdating
|
||||
{
|
||||
ASDisplayNodeAssert(self.asyncDataSouceLocked, @"The data source has already been unlocked !");
|
||||
|
||||
self.asyncDataSouceLocked = NO;
|
||||
|
||||
if ([_asyncDataSource respondsToSelector:@selector(tableViewUnlockDataSourceForDataUpdating:)]) {
|
||||
[_asyncDataSource tableViewUnlockDataSourceForDataUpdating:self];
|
||||
}
|
||||
}
|
||||
|
||||
- (NSUInteger)dataController:(ASDataController *)dataControllre rowsInSection:(NSUInteger)section
|
||||
{
|
||||
return [_asyncDataSource tableView:self numberOfRowsInSection:section];
|
||||
|
||||
Reference in New Issue
Block a user