mirror of
https://github.com/Instagram/IGListKit
synced 2026-05-06 06:58:26 +00:00
Summary: Updating license language to meet FB open source standards. Pull Request resolved: https://github.com/Instagram/IGListKit/pull/1272 Differential Revision: D12844366 Pulled By: rnystrom fbshipit-source-id: 27ae49ae00d963c5c012c79c5738365c232a5773
82 lines
3.3 KiB
Objective-C
82 lines
3.3 KiB
Objective-C
/**
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*/
|
|
|
|
#import <IGListKit/IGListReloadDataUpdater.h>
|
|
|
|
@implementation IGListReloadDataUpdater
|
|
|
|
#pragma mark - IGListUpdatingDelegate
|
|
|
|
- (NSPointerFunctions *)objectLookupPointerFunctions {
|
|
return [NSPointerFunctions pointerFunctionsWithOptions:NSPointerFunctionsObjectPersonality];
|
|
}
|
|
|
|
- (void)performUpdateWithCollectionViewBlock:(IGListCollectionViewBlock)collectionViewBlock
|
|
fromObjects:(NSArray *)fromObjects
|
|
toObjectsBlock:(IGListToObjectBlock)toObjectsBlock
|
|
animated:(BOOL)animated
|
|
objectTransitionBlock:(IGListObjectTransitionBlock)objectTransitionBlock
|
|
completion:(IGListUpdatingCompletion)completion {
|
|
if (toObjectsBlock != nil) {
|
|
NSArray *toObjects = toObjectsBlock() ?: @[];
|
|
objectTransitionBlock(toObjects);
|
|
}
|
|
[self _synchronousReloadDataWithCollectionView:collectionViewBlock()];
|
|
if (completion) {
|
|
completion(YES);
|
|
}
|
|
}
|
|
|
|
- (void)performUpdateWithCollectionViewBlock:(IGListCollectionViewBlock)collectionViewBlock
|
|
animated:(BOOL)animated
|
|
itemUpdates:(IGListItemUpdateBlock)itemUpdates
|
|
completion:(IGListUpdatingCompletion)completion {
|
|
itemUpdates();
|
|
[self _synchronousReloadDataWithCollectionView:collectionViewBlock()];
|
|
if (completion) {
|
|
completion(YES);
|
|
}
|
|
}
|
|
|
|
- (void)insertItemsIntoCollectionView:(UICollectionView *)collectionView indexPaths:(NSArray<NSIndexPath *> *)indexPaths {
|
|
[self _synchronousReloadDataWithCollectionView:collectionView];
|
|
}
|
|
|
|
- (void)deleteItemsFromCollectionView:(UICollectionView *)collectionView indexPaths:(NSArray<NSIndexPath *> *)indexPaths {
|
|
[self _synchronousReloadDataWithCollectionView:collectionView];
|
|
}
|
|
|
|
- (void)moveItemInCollectionView:(UICollectionView *)collectionView fromIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath {
|
|
[self _synchronousReloadDataWithCollectionView:collectionView];
|
|
}
|
|
|
|
- (void)reloadItemInCollectionView:(UICollectionView *)collectionView fromIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath {
|
|
[self _synchronousReloadDataWithCollectionView:collectionView];
|
|
}
|
|
|
|
- (void)moveSectionInCollectionView:(UICollectionView *)collectionView fromIndex:(NSInteger)fromIndex toIndex:(NSInteger)toIndex {
|
|
[self _synchronousReloadDataWithCollectionView:collectionView];
|
|
}
|
|
|
|
- (void)reloadDataWithCollectionViewBlock:(IGListCollectionViewBlock)collectionViewBlock reloadUpdateBlock:(IGListReloadUpdateBlock)reloadUpdateBlock completion:(IGListUpdatingCompletion)completion {
|
|
reloadUpdateBlock();
|
|
[self _synchronousReloadDataWithCollectionView:collectionViewBlock()];
|
|
if (completion) {
|
|
completion(YES);
|
|
}
|
|
}
|
|
|
|
- (void)reloadCollectionView:(UICollectionView *)collectionView sections:(NSIndexSet *)sections {
|
|
[self _synchronousReloadDataWithCollectionView:collectionView];
|
|
}
|
|
|
|
- (void)_synchronousReloadDataWithCollectionView:(UICollectionView *)collectionView {
|
|
[collectionView reloadData];
|
|
[collectionView layoutIfNeeded];
|
|
}
|
|
|
|
@end
|