Skip to content

Commit

Permalink
Updated the outdated files.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mahesh Shanbhag committed Jan 30, 2014
1 parent d21b882 commit aab9378
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
3 changes: 3 additions & 0 deletions Classes/RMDownloadIndicator.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ typedef enum {
// prepare the download indicator
- (void)loadIndicator;

// update the downloadIndicator
- (void)setIndicatorAnimationDuration:(CGFloat)duration;

// update the downloadIndicator
- (void)updateWithTotalBytes:(CGFloat)bytes downloadedBytes:(CGFloat)downloadedBytes;

Expand Down
24 changes: 21 additions & 3 deletions Classes/RMDownloadIndicator.m
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ @interface RMDownloadIndicator()
@property(nonatomic, strong)UIBezierPath *lastUpdatedPath;
@property(nonatomic, assign)CGFloat lastSourceAngle;

// this the animation duration (default: 0.5)
@property(nonatomic, assign)CGFloat animationDuration;


// this is display label that displays % downloaded
@property(nonatomic, strong)RMDisplayLabel *displayLabel;

Expand Down Expand Up @@ -117,6 +121,9 @@ - (void)initAttributes

// path array
_paths = [NSMutableArray array];

// animation duration
_animationDuration = 0.5;
}

- (void)addDisplayLabel
Expand All @@ -138,7 +145,7 @@ - (void)loadIndicator

if(_type == kRMClosedIndicator)
{
[initialPath addArcWithCenter:center radius:(MIN(CGRectGetWidth(self.bounds), CGRectGetHeight(self.bounds)) * self.radiusPercent) startAngle:degreeToRadian(-90) endAngle:degreeToRadian(-90) clockwise:YES]; //add the arc
[initialPath addArcWithCenter:center radius:(MIN(CGRectGetWidth(self.bounds), CGRectGetHeight(self.bounds))) startAngle:degreeToRadian(-90) endAngle:degreeToRadian(-90) clockwise:YES]; //add the arc
}
else
{
Expand Down Expand Up @@ -232,14 +239,14 @@ - (void)updateWithTotalBytes:(CGFloat)bytes downloadedBytes:(CGFloat)downloadedB
[_paths removeAllObjects];

CGFloat destinationAngle = [self destinationAngleForRatio:(downloadedBytes/bytes)];
[_paths addObjectsFromArray:[self keyframePathsWithDuration:1 sourceStartAngle:degreeToRadian(-90) sourceEndAngle:self.lastSourceAngle destinationStartAngle:degreeToRadian(-90) destinationEndAngle:destinationAngle centerPoint:center size:CGSizeMake(self.bounds.size.width, self.bounds.size.width) sourceRadiusPercent:_radiusPercent destinationRadiusPercent:_radiusPercent type:_type]];
[_paths addObjectsFromArray:[self keyframePathsWithDuration:self.animationDuration sourceStartAngle:degreeToRadian(-90) sourceEndAngle:self.lastSourceAngle destinationStartAngle:degreeToRadian(-90) destinationEndAngle:destinationAngle centerPoint:center size:CGSizeMake(self.bounds.size.width, self.bounds.size.width) sourceRadiusPercent:_radiusPercent destinationRadiusPercent:_radiusPercent type:_type]];

_animatingLayer.path = (__bridge CGPathRef)((id)_paths[(_paths.count -1)]);
self.lastSourceAngle = destinationAngle;

CAKeyframeAnimation *pathAnimation = [CAKeyframeAnimation animationWithKeyPath:@"path"];
[pathAnimation setValues:_paths];
[pathAnimation setDuration:1];
[pathAnimation setDuration:self.animationDuration];
[pathAnimation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut]];
[pathAnimation setRemovedOnCompletion:YES];
[_animatingLayer addAnimation:pathAnimation forKey:@"path"];
Expand Down Expand Up @@ -269,11 +276,22 @@ - (void)setFillColor:(UIColor *)fillColor

- (void)setRadiusPercent:(CGFloat)radiusPercent
{
if(_type == kRMClosedIndicator)
{
_radiusPercent = 0.5;
return;
}

if(radiusPercent > 0.5 || radiusPercent < 0)
return;
else
_radiusPercent = radiusPercent;

}

- (void)setIndicatorAnimationDuration:(CGFloat)duration
{
self.animationDuration = duration;
}

@end
Binary file not shown.

0 comments on commit aab9378

Please sign in to comment.