Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 44 additions & 9 deletions IOSBoilerplate/SVProgressHUD/SVProgressHUD.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,17 @@
#import <QuartzCore/QuartzCore.h>

@interface SVProgressHUD ()

#if !__has_feature(objc_arc)
@property (nonatomic, retain) NSTimer *fadeOutTimer;
@property (nonatomic, retain) UILabel *stringLabel;
@property (nonatomic, retain) UIImageView *imageView;
@property (nonatomic, retain) UIActivityIndicatorView *spinnerView;
#else
@property (nonatomic, strong) NSTimer *fadeOutTimer;
@property (nonatomic, strong) UILabel *stringLabel;
@property (nonatomic, strong) UIImageView *imageView;
@property (nonatomic, strong) UIActivityIndicatorView *spinnerView;
#endif

- (void)showInView:(UIView*)view status:(NSString*)string networkIndicator:(BOOL)show posY:(CGFloat)posY maskType:(SVProgressHUDMaskType)maskType;
- (void)setStatus:(NSString*)string;
Expand Down Expand Up @@ -126,12 +132,18 @@ + (void)dismissWithError:(NSString *)errorString afterDelay:(NSTimeInterval)seco

- (void)dealloc {

if(fadeOutTimer != nil)
[fadeOutTimer invalidate], [fadeOutTimer release], fadeOutTimer = nil;
if(fadeOutTimer != nil){
[fadeOutTimer invalidate];
#if !__has_feature(objc_arc)
[fadeOutTimer release];
#endif
fadeOutTimer = nil;
}

[[NSNotificationCenter defaultCenter] removeObserver:self];

#if !__has_feature(objc_arc)
[super dealloc];
#endif
}

- (id)initWithFrame:(CGRect)frame {
Expand Down Expand Up @@ -179,8 +191,13 @@ - (void)setStatus:(NSString *)string {

- (void)showInView:(UIView*)view status:(NSString*)string networkIndicator:(BOOL)show posY:(CGFloat)posY maskType:(SVProgressHUDMaskType)maskType {

if(fadeOutTimer != nil)
[fadeOutTimer invalidate], [fadeOutTimer release], fadeOutTimer = nil;
if(fadeOutTimer != nil){
[fadeOutTimer invalidate];
#if !__has_feature(objc_arc)
[fadeOutTimer release];
#endif
fadeOutTimer = nil;
}

if(show)
[UIApplication sharedApplication].networkActivityIndicatorVisible = YES;
Expand All @@ -197,7 +214,9 @@ - (void)showInView:(UIView*)view status:(NSString*)string networkIndicator:(BOOL
_maskView.backgroundColor = [UIColor clearColor];
_maskView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
[view addSubview:_maskView];
#if !__has_feature(objc_arc)
[_maskView release];
#endif
}

if(![sharedView isDescendantOfView:view]) {
Expand Down Expand Up @@ -272,10 +291,18 @@ - (void)dismissWithStatus:(NSString *)string error:(BOOL)error afterDelay:(NSTim

[self.spinnerView stopAnimating];

if(fadeOutTimer != nil)
[fadeOutTimer invalidate], [fadeOutTimer release], fadeOutTimer = nil;

if(fadeOutTimer != nil){
[fadeOutTimer invalidate];
#if !__has_feature(objc_arc)
[fadeOutTimer release];
#endif
fadeOutTimer = nil;
}
#if !__has_feature(objc_arc)
fadeOutTimer = [[NSTimer scheduledTimerWithTimeInterval:seconds target:self selector:@selector(dismiss) userInfo:nil repeats:NO] retain];
#else
fadeOutTimer = [NSTimer scheduledTimerWithTimeInterval:seconds target:self selector:@selector(dismiss) userInfo:nil repeats:NO];
#endif
}

#pragma mark - Getters
Expand All @@ -293,7 +320,9 @@ - (UILabel *)stringLabel {
stringLabel.shadowColor = [UIColor blackColor];
stringLabel.shadowOffset = CGSizeMake(0, -1);
[self addSubview:stringLabel];
#if !__has_feature(objc_arc)
[stringLabel release];
#endif
}

return stringLabel;
Expand All @@ -304,7 +333,9 @@ - (UIImageView *)imageView {
if (imageView == nil) {
imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 28, 28)];
[self addSubview:imageView];
#if !__has_feature(objc_arc)
[imageView release];
#endif
}

return imageView;
Expand All @@ -317,7 +348,9 @@ - (UIActivityIndicatorView *)spinnerView {
spinnerView.hidesWhenStopped = YES;
spinnerView.bounds = CGRectMake(0, 0, 37, 37);
[self addSubview:spinnerView];
#if !__has_feature(objc_arc)
[spinnerView release];
#endif
}

return spinnerView;
Expand All @@ -328,7 +361,9 @@ - (UIActivityIndicatorView *)spinnerView {
- (void)memoryWarning:(NSNotification *)notification {

if (sharedView.superview == nil) {
#if !__has_feature(objc_arc)
[sharedView release];
#endif
sharedView = nil;
}
}
Expand Down