Fix collection editing (#1081)

* fix SIMULATE_WEB_RESPONSE not imported #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
This commit is contained in:
Max Wang
2018-09-05 08:08:46 -07:00
committed by Michael Schneider
parent eba4e290a5
commit dbcf8babb8
2 changed files with 30 additions and 3 deletions

View File

@@ -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)

View File

@@ -139,6 +139,12 @@ static NSString * const kReuseIdentifier = @"_ASCollectionReuseIdentifier";
* (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.
@@ -1013,9 +1019,29 @@ static NSString * const kReuseIdentifier = @"_ASCollectionReuseIdentifier";
- (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 -