diff --git a/Source/IGListKit/IGListAdapterUpdater.m b/Source/IGListKit/IGListAdapterUpdater.m index 9cc40257..d2c10297 100644 --- a/Source/IGListKit/IGListAdapterUpdater.m +++ b/Source/IGListKit/IGListAdapterUpdater.m @@ -264,7 +264,8 @@ willPerformBatchUpdatesWithCollectionView:collectionView fromObjects:fromObjects toObjects:toObjects - listIndexSetResult:result]; + listIndexSetResult:result + animated:animated]; if (animated) { [collectionView performBatchUpdates:^{ batchUpdatesBlock(result); diff --git a/Source/IGListKit/IGListAdapterUpdaterDelegate.h b/Source/IGListKit/IGListAdapterUpdaterDelegate.h index e4e7d695..0f9aee84 100644 --- a/Source/IGListKit/IGListAdapterUpdaterDelegate.h +++ b/Source/IGListKit/IGListAdapterUpdaterDelegate.h @@ -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 > *)fromObjects toObjects:(nullable NSArray > *)toObjects - listIndexSetResult:(nullable IGListIndexSetResult *)listIndexSetResults; + listIndexSetResult:(nullable IGListIndexSetResult *)listIndexSetResults + animated:(BOOL)animated; /** Notifies the delegate that the updater successfully finished `-[UICollectionView performBatchUpdates:completion:]`. diff --git a/Tests/IGListAdapterUpdaterTests.m b/Tests/IGListAdapterUpdaterTests.m index 55fb6782..da5a38d5 100644 --- a/Tests/IGListAdapterUpdaterTests.m +++ b/Tests/IGListAdapterUpdaterTests.m @@ -504,7 +504,7 @@ NSArray *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;