Skip to content

Commit

Permalink
Fix collection editing (TextureGroup#1081)
Browse files Browse the repository at this point in the history
* fix SIMULATE_WEB_RESPONSE not imported TextureGroup#449

* Fix to make rangeMode update in right time

* remove uncessary assert

* Fix collection cell editing bug for iOS 9 & 10

* Rename to reordering.

* Adjust _reordering more acuratedly

* Add change log
  • Loading branch information
wsdwsd0829 authored and mikezucc committed Oct 2, 2018
1 parent 90e97d9 commit 339c5f3
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## master
* Add your own contributions to the next release on the line below this with your name.
- [ASCollectionView] Fix reording of cells manually for iOS 9 & 10. [Max Wang](https://github.com/wsdwsd0829). [#1081](https://github.com/TextureGroup/Texture/pull/1081)
- [ASDisplayNode] Allow add/remove interface state delegates on background thread. [Max Wang](https://github.com/wsdwsd0829). [#1090](https://github.com/TextureGroup/Texture/pull/1090)
- [License] Simplify the Texture license to be pure Apache 2 (removing ASDK-Licenses).[Scott Goodson](https://github.com/appleguy) [#1077](https://github.com/TextureGroup/Texture/pull/1077)
- [ASNetworkImageNode] Allow delegate methods to be called on background thread. [Max Wang](https://github.com/wsdwsd0829). [#1007](https://github.com/TextureGroup/Texture/pull/1007)
Expand Down
32 changes: 29 additions & 3 deletions Source/ASCollectionView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,12 @@ @interface ASCollectionView () <ASRangeControllerDataSource, ASRangeControllerDe
* (0 sections) we always check at least once after each update (initial reload is the first update.)
*/
BOOL _hasEverCheckedForBatchFetchingDueToUpdate;

/**
* Set during beginInteractiveMovementForItemAtIndexPath and UIGestureRecognizerStateEnded
* (or UIGestureRecognizerStateFailed, UIGestureRecognizerStateCancelled.
*/
BOOL _reordering;

/**
* Counter used to keep track of nested batch updates.
Expand Down Expand Up @@ -1013,9 +1019,29 @@ - (void)reloadItemsAtIndexPaths:(NSArray *)indexPaths
- (void)moveItemAtIndexPath:(NSIndexPath *)indexPath toIndexPath:(NSIndexPath *)newIndexPath
{
ASDisplayNodeAssertMainThread();
[self performBatchUpdates:^{
[_changeSet moveItemAtIndexPath:indexPath toIndexPath:newIndexPath animationOptions:kASCollectionViewAnimationNone];
} completion:nil];
if (!_reordering) {
[self performBatchUpdates:^{
[_changeSet moveItemAtIndexPath:indexPath toIndexPath:newIndexPath animationOptions:kASCollectionViewAnimationNone];
} completion:nil];
} else {
[super moveItemAtIndexPath:indexPath toIndexPath:newIndexPath];
}
}

- (BOOL)beginInteractiveMovementForItemAtIndexPath:(NSIndexPath *)indexPath {
BOOL success = [super beginInteractiveMovementForItemAtIndexPath:indexPath];
_reordering = success;
return success;
}

- (void)endInteractiveMovement {
_reordering = NO;
[super endInteractiveMovement];
}

- (void)cancelInteractiveMovement {
_reordering = NO;
[super cancelInteractiveMovement];
}

#pragma mark -
Expand Down

0 comments on commit 339c5f3

Please sign in to comment.