Skip to content

Commit

Permalink
Handle moveItemFromIndextoIndex properly
Browse files Browse the repository at this point in the history
  • Loading branch information
saiday committed Mar 2, 2016
1 parent 83331cd commit 1fe05a0
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions HysteriaPlayer/HysteriaPlayer.m
Original file line number Diff line number Diff line change
Expand Up @@ -428,12 +428,17 @@ - (void)moveItemFromIndex:(NSInteger)from toIndex:(NSInteger)to
- (BOOL)resetItemIndexIfNeeds:(AVPlayerItem *)item fromIndex:(NSInteger)sourceIndex toIndex:(NSInteger)destinationIndex
{
NSInteger checkIndex = [[self getHysteriaIndex:item] integerValue];
if (checkIndex == sourceIndex || checkIndex == destinationIndex) {
NSNumber *replaceOrder = checkIndex == sourceIndex ? [NSNumber numberWithInteger:destinationIndex] : [NSNumber numberWithInteger:sourceIndex];
BOOL found = NO;
if (checkIndex == sourceIndex) {
NSNumber *replaceOrder = [NSNumber numberWithInteger:destinationIndex];
[self setHysteriaIndex:item key:replaceOrder];
found = YES;
} else if (checkIndex >= destinationIndex) {
NSNumber *replaceOrder = [NSNumber numberWithInteger:(checkIndex + 1)];
[self setHysteriaIndex:item key:replaceOrder];
return YES;
}
return NO;

return found;
}

- (void)seekToTime:(double)seconds
Expand Down

0 comments on commit 1fe05a0

Please sign in to comment.