Skip to content

Commit

Permalink
Fix last commit, handle moveItemFromIndex:toIndex:
Browse files Browse the repository at this point in the history
  • Loading branch information
saiday committed Mar 3, 2016
1 parent 1fe05a0 commit 171898d
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions HysteriaPlayer/HysteriaPlayer.m
Original file line number Diff line number Diff line change
Expand Up @@ -429,15 +429,27 @@ - (BOOL)resetItemIndexIfNeeds:(AVPlayerItem *)item fromIndex:(NSInteger)sourceIn
{
NSInteger checkIndex = [[self getHysteriaIndex:item] integerValue];
BOOL found = NO;
NSNumber *replaceOrder;
if (checkIndex == sourceIndex) {
NSNumber *replaceOrder = [NSNumber numberWithInteger:destinationIndex];
[self setHysteriaIndex:item key:replaceOrder];
replaceOrder = [NSNumber numberWithInteger:destinationIndex];
found = YES;
} else if (checkIndex == destinationIndex) {
replaceOrder = sourceIndex > checkIndex ? @(checkIndex + 1) : @(checkIndex - 1);
found = YES;
} else if (checkIndex > destinationIndex && checkIndex < sourceIndex) {
replaceOrder = [NSNumber numberWithInteger:(checkIndex + 1)];
found = YES;
} else if (checkIndex < destinationIndex && checkIndex > sourceIndex) {
replaceOrder = [NSNumber numberWithInteger:(checkIndex - 1)];
found = YES;
} else if (checkIndex >= destinationIndex) {
NSNumber *replaceOrder = [NSNumber numberWithInteger:(checkIndex + 1)];
}

if (replaceOrder) {
[self setHysteriaIndex:item key:replaceOrder];
if (self.lastItemIndex == checkIndex) {
self.lastItemIndex = [replaceOrder integerValue];
}
}

return found;
}

Expand Down

0 comments on commit 171898d

Please sign in to comment.