Skip to content

Commit

Permalink
Update weak references
Browse files Browse the repository at this point in the history
  • Loading branch information
leverdeterre committed Oct 1, 2014
1 parent 9ea9503 commit 5732305
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,29 +65,31 @@ - (void)moveCurrentCardImageFromIndex:(NSInteger)fromIndex

for (int i = 0; i < (int)abs((int)shift) ; i++) {

NSInteger index = [self realIndexForComputedIndex:fromIndex+i*shiftUnit];
JMGifItem *item = [[self.gifObject items] objectAtIndex:index];
NSInteger index = [self realIndexForComputedIndex:fromIndex+i*shiftUnit];
JMGifItem *item = [[self.gifObject items] objectAtIndex:index];

JMAnimationOperation *operation = [JMAnimationOperation animationOperationWithDuration:item.delayDuration
completion:^(BOOL finished)
{

if (self.animationType == JMAnimatedImageViewAnimationTypeAutomaticLinearWithoutTransition) {
if ([self operationQueueIsFinished] == YES) {
if (finishBlock) {
finishBlock(YES);
}

if (self.animationRepeatCount == 0 && self.animationState == UIImageViewAnimationStateInPgrogress) {
[self continueAnimating];
}
__weak JMAnimatedGifImageView *weaSelf = self;
JMAnimationOperation *operation = [JMAnimationOperation animationOperationWithDuration:item.delayDuration
completion:^(BOOL finished)
{

if (weaSelf.animationType == JMAnimatedImageViewAnimationTypeAutomaticLinearWithoutTransition) {
if ([weaSelf operationQueueIsFinished] == YES) {
if (finishBlock) {
finishBlock(YES);
}

if (weaSelf.animationRepeatCount == 0 &&
weaSelf.animationState == UIImageViewAnimationStateInPgrogress) {
[weaSelf continueAnimating];
}
}
}];

operation.animatedImageView = self;
operation.imageIndex = index;
[self.animationQueue addOperation:operation];
}
}];

operation.animatedImageView = self;
operation.imageIndex = index;
[self.animationQueue addOperation:operation];
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -369,19 +369,23 @@ - (void)moveCurrentCardImageFromIndex:(NSInteger)fromIndex
continue;

} else {

NSInteger index = [self realIndexForComputedIndex:fromIndex+i*shiftUnit];
__weak JMAnimatedImageView *weaSelf = self;

JMAnimationOperation *operation = [JMAnimationOperation animationOperationWithDuration:currentInterval
completion:^(BOOL finished)
{

if (self.animationType == JMAnimatedImageViewAnimationTypeAutomaticLinearWithoutTransition) {
if ([self operationQueueIsFinished] == YES) {
if (weaSelf.animationType == JMAnimatedImageViewAnimationTypeAutomaticLinearWithoutTransition) {
if ([weaSelf operationQueueIsFinished] == YES) {
if (finishBlock) {
finishBlock(YES);
}

if (self.animationRepeatCount == 0 && self.animationState == UIImageViewAnimationStateInPgrogress) {
[self continueAnimating];
if (weaSelf.animationRepeatCount == 0 &&
weaSelf.animationState == UIImageViewAnimationStateInPgrogress) {
[weaSelf continueAnimating];
}
}
}
Expand Down

0 comments on commit 5732305

Please sign in to comment.