mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-24 07:05:35 +00:00
Fix table view
This commit is contained in:
@@ -189,7 +189,7 @@ static BOOL _isInterceptedSelector(SEL sel)
|
||||
ASDisplayNodePerformBlockOnMainThread(^{
|
||||
[super reloadData];
|
||||
});
|
||||
[_dataController reloadData];
|
||||
[_dataController reloadDataWithAnimationOption:UITableViewRowAnimationNone];
|
||||
}
|
||||
|
||||
- (ASRangeTuningParameters)rangeTuningParameters
|
||||
@@ -238,7 +238,7 @@ static BOOL _isInterceptedSelector(SEL sel)
|
||||
|
||||
- (void)moveSection:(NSInteger)section toSection:(NSInteger)newSection
|
||||
{
|
||||
[_dataController moveSection:section toSection:newSection];
|
||||
[_dataController moveSection:section toSection:newSection withAnimationOption:UITableViewRowAnimationNone];
|
||||
}
|
||||
|
||||
- (void)insertRowsAtIndexPaths:(NSArray *)indexPaths withRowAnimation:(UITableViewRowAnimation)animation
|
||||
@@ -258,7 +258,7 @@ static BOOL _isInterceptedSelector(SEL sel)
|
||||
|
||||
- (void)moveRowAtIndexPath:(NSIndexPath *)indexPath toIndexPath:(NSIndexPath *)newIndexPath
|
||||
{
|
||||
[_dataController moveRowAtIndexPath:indexPath toIndexPath:newIndexPath];
|
||||
[_dataController moveRowAtIndexPath:indexPath toIndexPath:newIndexPath withAnimationOption:UITableViewRowAnimationNone];
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
@@ -372,36 +372,28 @@ static BOOL _isInterceptedSelector(SEL sel)
|
||||
{
|
||||
ASDisplayNodeAssertMainThread();
|
||||
|
||||
// [UIView performWithoutAnimation:^{
|
||||
[super insertRowsAtIndexPaths:indexPaths withRowAnimation:(UITableViewRowAnimation)animationOption];
|
||||
// }];
|
||||
[super insertRowsAtIndexPaths:indexPaths withRowAnimation:(UITableViewRowAnimation)animationOption];
|
||||
}
|
||||
|
||||
- (void)rangeController:(ASRangeController *)rangeController didDeleteNodesAtIndexPaths:(NSArray *)indexPaths withAnimationOption:(ASDataControllerAnimationOptions)animationOption
|
||||
{
|
||||
ASDisplayNodeAssertMainThread();
|
||||
|
||||
// [UIView performWithoutAnimation:^{
|
||||
[super deleteRowsAtIndexPaths:indexPaths withRowAnimation:(UITableViewRowAnimation)animationOption];
|
||||
// }];
|
||||
[super deleteRowsAtIndexPaths:indexPaths withRowAnimation:(UITableViewRowAnimation)animationOption];
|
||||
}
|
||||
|
||||
- (void)rangeController:(ASRangeController *)rangeController didInsertSectionsAtIndexSet:(NSIndexSet *)indexSet withAnimationOption:(ASDataControllerAnimationOptions)animationOption
|
||||
{
|
||||
ASDisplayNodeAssertMainThread();
|
||||
|
||||
// [UIView performWithoutAnimation:^{
|
||||
[super insertSections:indexSet withRowAnimation:(UITableViewRowAnimation)animationOption];
|
||||
// }];
|
||||
[super insertSections:indexSet withRowAnimation:(UITableViewRowAnimation)animationOption];
|
||||
}
|
||||
|
||||
- (void)rangeController:(ASRangeController *)rangeController didDeleteSectionsAtIndexSet:(NSIndexSet *)indexSet withAnimationOption:(ASDataControllerAnimationOptions)animationOption
|
||||
{
|
||||
ASDisplayNodeAssertMainThread();
|
||||
|
||||
// [UIView performWithoutAnimation:^{
|
||||
[super deleteSections:indexSet withRowAnimation:(UITableViewRowAnimation)animationOption];
|
||||
// }];
|
||||
[super deleteSections:indexSet withRowAnimation:(UITableViewRowAnimation)animationOption];
|
||||
}
|
||||
|
||||
#pragma mark - ASDataControllerDelegate
|
||||
|
||||
@@ -98,7 +98,7 @@ typedef NSUInteger ASDataControllerAnimationOptions;
|
||||
|
||||
/** @name Initial loading */
|
||||
|
||||
- (void)initialDataLoading;
|
||||
- (void)initialDataLoadingWithAnimationOption:(ASDataControllerAnimationOptions)animationOption;
|
||||
|
||||
/** @name Data Updating */
|
||||
|
||||
@@ -112,7 +112,7 @@ typedef NSUInteger ASDataControllerAnimationOptions;
|
||||
|
||||
- (void)reloadSections:(NSIndexSet *)sections withAnimationOption:(ASDataControllerAnimationOptions)animationOption;
|
||||
|
||||
- (void)moveSection:(NSInteger)section toSection:(NSInteger)newSection;
|
||||
- (void)moveSection:(NSInteger)section toSection:(NSInteger)newSection withAnimationOption:(ASDataControllerAnimationOptions)animationOption;;
|
||||
|
||||
- (void)insertRowsAtIndexPaths:(NSArray *)indexPaths withAnimationOption:(ASDataControllerAnimationOptions)animationOption;
|
||||
|
||||
@@ -120,9 +120,9 @@ typedef NSUInteger ASDataControllerAnimationOptions;
|
||||
|
||||
- (void)reloadRowsAtIndexPaths:(NSArray *)indexPaths withAnimationOption:(ASDataControllerAnimationOptions)animationOption;
|
||||
|
||||
- (void)moveRowAtIndexPath:(NSIndexPath *)indexPath toIndexPath:(NSIndexPath *)newIndexPath;
|
||||
- (void)moveRowAtIndexPath:(NSIndexPath *)indexPath toIndexPath:(NSIndexPath *)newIndexPath withAnimationOption:(ASDataControllerAnimationOptions)animationOption;;
|
||||
|
||||
- (void)reloadData;
|
||||
- (void)reloadDataWithAnimationOption:(ASDataControllerAnimationOptions)animationOption;;
|
||||
|
||||
/** @name Data Querying */
|
||||
|
||||
|
||||
@@ -71,7 +71,6 @@
|
||||
#define ENABLE_BACKGROUND_UPDATE 0
|
||||
|
||||
const static NSUInteger kASDataControllerSizingCountPerProcessor = 5;
|
||||
const static NSUInteger kASDataControllerAnimationOptionNone = 0;
|
||||
|
||||
static void *kASSizingQueueContext = &kASSizingQueueContext;
|
||||
static void *kASDataUpdatingQueueContext = &kASDataUpdatingQueueContext;
|
||||
@@ -186,7 +185,7 @@ static void *kASDataUpdatingQueueContext = &kASDataUpdatingQueueContext;
|
||||
|
||||
#pragma mark - Initial Data Loading
|
||||
|
||||
- (void)initialDataLoading {
|
||||
- (void)initialDataLoadingWithAnimationOption:(ASDataControllerAnimationOptions)animationOption {
|
||||
NSMutableArray *indexPaths = [NSMutableArray array];
|
||||
|
||||
NSUInteger sectionNum = [_dataSource dataControllerNumberOfSections:self];
|
||||
@@ -204,7 +203,7 @@ static void *kASDataUpdatingQueueContext = &kASDataUpdatingQueueContext;
|
||||
}
|
||||
|
||||
// insert elements
|
||||
[self insertRowsAtIndexPaths:indexPaths withAnimationOption:kASDataControllerAnimationOptionNone];
|
||||
[self insertRowsAtIndexPaths:indexPaths withAnimationOption:animationOption];
|
||||
}
|
||||
|
||||
#pragma mark - Data Update
|
||||
@@ -305,13 +304,13 @@ static void *kASDataUpdatingQueueContext = &kASDataUpdatingQueueContext;
|
||||
});
|
||||
}
|
||||
|
||||
- (void)moveSection:(NSInteger)section toSection:(NSInteger)newSection {
|
||||
- (void)moveSection:(NSInteger)section toSection:(NSInteger)newSection withAnimationOption:(ASDataControllerAnimationOptions)animationOption {
|
||||
dispatch_async([ASDataController sizingQueue], ^{
|
||||
[self asyncUpdateDataWithBlock:^{
|
||||
// remove elements
|
||||
NSArray *indexPaths = ASIndexPathsForMultidimensionalArrayAtIndexSet(_nodes, [NSIndexSet indexSetWithIndex:section]);
|
||||
NSArray *nodes = ASFindElementsInMultidimensionalArrayAtIndexPaths(_nodes, indexPaths);
|
||||
DELETE_NODES(_nodes, indexPaths, kASDataControllerAnimationOptionNone);
|
||||
DELETE_NODES(_nodes, indexPaths, animationOption);
|
||||
|
||||
// update the section of indexpaths
|
||||
NSIndexPath *sectionIndexPath = [[NSIndexPath alloc] initWithIndex:newSection];
|
||||
@@ -321,7 +320,7 @@ static void *kASDataUpdatingQueueContext = &kASDataUpdatingQueueContext;
|
||||
}];
|
||||
|
||||
// Don't re-calculate size for moving
|
||||
INSERT_NODES(_nodes, updatedIndexPaths, nodes, kASDataControllerAnimationOptionNone);
|
||||
INSERT_NODES(_nodes, updatedIndexPaths, nodes, animationOption);
|
||||
}];
|
||||
});
|
||||
}
|
||||
@@ -423,21 +422,21 @@ static void *kASDataUpdatingQueueContext = &kASDataUpdatingQueueContext;
|
||||
});
|
||||
}
|
||||
|
||||
- (void)moveRowAtIndexPath:(NSIndexPath *)indexPath toIndexPath:(NSIndexPath *)newIndexPath {
|
||||
- (void)moveRowAtIndexPath:(NSIndexPath *)indexPath toIndexPath:(NSIndexPath *)newIndexPath withAnimationOption:(ASDataControllerAnimationOptions)animationOption {
|
||||
dispatch_async([ASDataController sizingQueue], ^{
|
||||
[self asyncUpdateDataWithBlock:^{
|
||||
NSArray *nodes = ASFindElementsInMultidimensionalArrayAtIndexPaths(_nodes, [NSArray arrayWithObject:indexPath]);
|
||||
NSArray *indexPaths = [NSArray arrayWithObject:indexPath];
|
||||
DELETE_NODES(_nodes, indexPaths, kASDataControllerAnimationOptionNone);
|
||||
DELETE_NODES(_nodes, indexPaths, animationOption);
|
||||
|
||||
// Don't re-calculate size for moving
|
||||
NSArray *newIndexPaths = [NSArray arrayWithObject:newIndexPath];
|
||||
INSERT_NODES(_nodes, newIndexPaths, nodes, kASDataControllerAnimationOptionNone);
|
||||
INSERT_NODES(_nodes, newIndexPaths, nodes, animationOption);
|
||||
}];
|
||||
});
|
||||
}
|
||||
|
||||
- (void)reloadData {
|
||||
- (void)reloadDataWithAnimationOption:(ASDataControllerAnimationOptions)animationOption {
|
||||
// Fetching data in calling thread
|
||||
NSMutableArray *updatedNodes = [[NSMutableArray alloc] init];
|
||||
NSMutableArray *updatedIndexPaths = [[NSMutableArray alloc] init];
|
||||
@@ -458,10 +457,10 @@ static void *kASDataUpdatingQueueContext = &kASDataUpdatingQueueContext;
|
||||
[self syncUpdateDataWithBlock:^{
|
||||
|
||||
NSArray *indexPaths = ASIndexPathsForMultidimensionalArray(_nodes);
|
||||
DELETE_NODES(_nodes, indexPaths, kASDataControllerAnimationOptionNone);
|
||||
DELETE_NODES(_nodes, indexPaths, animationOption);
|
||||
|
||||
NSMutableIndexSet *indexSet = [[NSMutableIndexSet alloc] initWithIndexesInRange:NSMakeRange(0, _nodes.count)];
|
||||
DELETE_SECTIONS(_nodes, indexSet, kASDataControllerAnimationOptionNone);
|
||||
DELETE_SECTIONS(_nodes, indexSet, animationOption);
|
||||
|
||||
|
||||
// Insert section
|
||||
@@ -471,11 +470,11 @@ static void *kASDataUpdatingQueueContext = &kASDataUpdatingQueueContext;
|
||||
[sections addObject:[[NSMutableArray alloc] init]];
|
||||
}
|
||||
|
||||
INSERT_SECTIONS(_nodes, [[NSMutableIndexSet alloc] initWithIndexesInRange:NSMakeRange(0, sectionNum)], sections, kASDataControllerAnimationOptionNone);
|
||||
INSERT_SECTIONS(_nodes, [[NSMutableIndexSet alloc] initWithIndexesInRange:NSMakeRange(0, sectionNum)], sections, animationOption);
|
||||
|
||||
}];
|
||||
|
||||
[self _batchInsertNodes:updatedNodes atIndexPaths:updatedIndexPaths withAnimationOptions:kASDataControllerAnimationOptionNone];
|
||||
[self _batchInsertNodes:updatedNodes atIndexPaths:updatedIndexPaths withAnimationOptions:animationOption];
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user