add animated to IGListAdapterUpdaterDelegate

Summary: The duration of an update depends a lot of if it's animated, so lets pass that info to the delegate.

Reviewed By: lorixx

Differential Revision: D22265405

fbshipit-source-id: 4d164447384b84eb6f41c7f8365d0b28670e1372
This commit is contained in:
Maxime Ollivier 2020-06-30 10:11:35 -07:00 committed by Facebook GitHub Bot
parent e3e26c4b4b
commit 97b0a13a59
3 changed files with 13 additions and 10 deletions

View file

@ -264,7 +264,8 @@
willPerformBatchUpdatesWithCollectionView:collectionView
fromObjects:fromObjects
toObjects:toObjects
listIndexSetResult:result];
listIndexSetResult:result
animated:animated];
if (animated) {
[collectionView performBatchUpdates:^{
batchUpdatesBlock(result);

View file

@ -29,12 +29,14 @@ NS_SWIFT_NAME(ListAdapterUpdaterDelegate)
@param fromObjects The items transitioned from in the batch updates, if any.
@param toObjects The items transitioned to in the batch updates, if any.
@param listIndexSetResults The diffing result of indices to be inserted/removed/updated/moved/etc.
@param animated Is the cell transtion animated
*/
- (void) listAdapterUpdater:(IGListAdapterUpdater *)listAdapterUpdater
willPerformBatchUpdatesWithCollectionView:(UICollectionView *)collectionView
fromObjects:(nullable NSArray <id<IGListDiffable>> *)fromObjects
toObjects:(nullable NSArray <id<IGListDiffable>> *)toObjects
listIndexSetResult:(nullable IGListIndexSetResult *)listIndexSetResults;
listIndexSetResult:(nullable IGListIndexSetResult *)listIndexSetResults
animated:(BOOL)animated;
/**
Notifies the delegate that the updater successfully finished `-[UICollectionView performBatchUpdates:completion:]`.

View file

@ -504,7 +504,7 @@
NSArray<IGSectionObject *> *to = @[[IGSectionObject sectionWithObjects:@[]]];
[[mockDelegate expect] listAdapterUpdater:self.updater willPerformBatchUpdatesWithCollectionView:self.collectionView fromObjects:self.dataSource.sections toObjects:to listIndexSetResult:[OCMArg checkWithBlock:^BOOL(IGListIndexSetResult *result) {
return result.inserts.firstIndex == 0 && result.moves.count == 0 && result.updates.count == 0 && result.deletes.count == 0;
}]];
}] animated:NO];
[[mockDelegate expect] listAdapterUpdater:self.updater didPerformBatchUpdates:OCMOCK_ANY collectionView:self.collectionView];
XCTestExpectation *expectation = genExpectation;
@ -707,7 +707,7 @@
[mockDelegate setExpectationOrderMatters:YES];
[[mockDelegate expect] listAdapterUpdater:self.updater willPerformBatchUpdatesWithCollectionView:self.collectionView fromObjects:from toObjects:to listIndexSetResult:[OCMArg checkWithBlock:^BOOL(IGListIndexSetResult *result) {
return result.inserts.count == 0 && result.deletes.count == 0 && result.moves.count == 0 && result.updates.firstIndex == 0;
}]];
}] animated:NO];
[[mockDelegate expect] listAdapterUpdater:self.updater didPerformBatchUpdates:expectedBatchUpdateData collectionView:self.collectionView];
XCTestExpectation *expectation = genExpectation;
@ -835,7 +835,7 @@
[mockDelegate setExpectationOrderMatters:YES];
[[mockDelegate expect] listAdapterUpdater:self.updater willPerformBatchUpdatesWithCollectionView:self.collectionView fromObjects:from toObjects:to listIndexSetResult:[OCMArg checkWithBlock:^BOOL(IGListIndexSetResult *result) {
return result.inserts.count == 0 && result.deletes.count == 0 && result.moves.count == 0 && result.updates.firstIndex == 0;
}]];
}] animated:NO];
[[mockDelegate expect] listAdapterUpdater:self.updater didPerformBatchUpdates:expectedBatchUpdateData collectionView:self.collectionView];
XCTestExpectation *expectation = genExpectation;
@ -867,7 +867,7 @@
[mockDelegate setExpectationOrderMatters:YES];
[[mockDelegate expect] listAdapterUpdater:self.updater willPerformBatchUpdatesWithCollectionView:self.collectionView fromObjects:from toObjects:to listIndexSetResult:[OCMArg checkWithBlock:^BOOL(IGListIndexSetResult *result) {
return result.inserts.count == 0 && result.deletes.count == 0 && result.moves.count == 0 && result.updates.firstIndex == 0;
}]];
}] animated:NO];
[[mockDelegate expect] listAdapterUpdater:self.updater didPerformBatchUpdates:expectedBatchUpdateData collectionView:self.collectionView];
XCTestExpectation *expectation = genExpectation;
@ -905,7 +905,7 @@
}
// Make sure we note that index 1 is updated (id2 from @[@2] -> @[@22], "id1" moved from section 0 -> 1, and "id2" moved from section 1 -> 0
return result.updates.firstIndex == 1 && result.moves.count == 2 && [result.moves containsObject:[[IGListMoveIndex alloc] initWithFrom:0 to:1]] && [result.moves containsObject:[[IGListMoveIndex alloc] initWithFrom:1 to:0]];
}]];
}] animated:NO];
[[mockDelegate expect] listAdapterUpdater:self.updater didPerformBatchUpdates:expectedBatchUpdateData collectionView:self.collectionView];
XCTestExpectation *expectation = genExpectation;
@ -943,7 +943,7 @@
}
// Make sure we note that index 1 is updated (id2 from @[@2] -> @[@22], "id1" moved from section 0 -> 1, and "id2" moved from section 1 -> 0
return result.updates.firstIndex == 1 && result.moves.count == 2 && [result.moves containsObject:[[IGListMoveIndex alloc] initWithFrom:0 to:1]] && [result.moves containsObject:[[IGListMoveIndex alloc] initWithFrom:1 to:0]];
}]];
}] animated:NO];
[[mockDelegate expect] listAdapterUpdater:self.updater didPerformBatchUpdates:expectedBatchUpdateData collectionView:self.collectionView];
XCTestExpectation *expectation = genExpectation;
@ -983,7 +983,7 @@
}
// Make sure we note that index 1 is updated (id2 from @[@2] -> @[@22], "id1" moved from section 0 -> 1, "id2" moved from section 1 -> 0
return result.updates.firstIndex == 1 && result.moves.count == 2 && [result.moves containsObject:[[IGListMoveIndex alloc] initWithFrom:0 to:1]] && [result.moves containsObject:[[IGListMoveIndex alloc] initWithFrom:1 to:0]];
}]];
}] animated:NO];
[[mockDelegate expect] listAdapterUpdater:self.updater didPerformBatchUpdates:expectedBatchUpdateData collectionView:self.collectionView];
XCTestExpectation *expectation = genExpectation;
@ -1018,7 +1018,7 @@
}
// Make sure we note that index 1 is updated (id1 from @[@1] -> @[@2]), and "id2" was inserted at index 1
return result.updates.firstIndex == 0 && result.inserts.firstIndex == 1;
}]];
}] animated:NO];
[[mockDelegate expect] listAdapterUpdater:self.updater didPerformBatchUpdates:expectedBatchUpdateData collectionView:self.collectionView];
XCTestExpectation *expectation = genExpectation;