Skip to content

Commit

Permalink
Updated to latest version of MBProgressHUD which included a bug fix.
Browse files Browse the repository at this point in the history
  • Loading branch information
mwaterfall committed Jan 19, 2012
1 parent d4e7525 commit aa4fd90
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 20 deletions.
2 changes: 1 addition & 1 deletion MWPhotoBrowser/Classes/MWPhotoBrowser.m
Expand Up @@ -1045,7 +1045,7 @@ - (void)actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSIn
- (MBProgressHUD *)progressHUD {
if (!_progressHUD) {
_progressHUD = [[MBProgressHUD alloc] initWithView:self.view];
_progressHUD.minSize = CGSizeMake(110, 110);
_progressHUD.minSize = CGSizeMake(120, 120);
_progressHUD.minShowTime = 1;
// The sample image is based on the
// work by: http://www.pixelpressicons.com
Expand Down
28 changes: 22 additions & 6 deletions MWPhotoBrowser/Libraries/MBProgressHUD/MBProgressHUD.h
Expand Up @@ -104,8 +104,12 @@ typedef enum {

float progress;

#if __has_feature(objc_arc)
id<MBProgressHUDDelegate> __weak delegate;
#else
id<MBProgressHUDDelegate> delegate;
NSString *labelText;
#endif
NSString *labelText;
NSString *detailsLabelText;
float opacity;
UIFont *labelFont;
Expand All @@ -132,7 +136,7 @@ typedef enum {
+ (MBProgressHUD *)showHUDAddedTo:(UIView *)view animated:(BOOL)animated;

/**
* Finds a HUD sibview and hides it. The counterpart to this method is showHUDAddedTo:animated:.
* Finds a HUD subview and hides it. The counterpart to this method is showHUDAddedTo:animated:.
*
* @param view The view that is going to be searched for a HUD subview.
* @param animated If set to YES the HUD will disappear using the current animationType. If set to NO the HUD will not use
Expand Down Expand Up @@ -165,8 +169,11 @@ typedef enum {
* The UIView (i.g., a UIIMageView) to be shown when the HUD is in MBProgressHUDModeCustomView.
* For best results use a 37 by 37 pixel view (so the bounds match the build in indicator bounds).
*/
#if __has_feature(objc_arc)
@property (strong) UIView *customView;
#else
@property (retain) UIView *customView;

#endif
/**
* MBProgressHUD operation mode. Switches between indeterminate (MBProgressHUDModeIndeterminate) and determinate
* progress (MBProgressHUDModeDeterminate). The default is MBProgressHUDModeIndeterminate.
Expand All @@ -187,8 +194,11 @@ typedef enum {
* delegate should conform to the MBProgressHUDDelegate protocol and implement the hudWasHidden method. The delegate
* object will not be retained.
*/
#if __has_feature(objc_arc)
@property (weak) id<MBProgressHUDDelegate> delegate;
#else
@property (assign) id<MBProgressHUDDelegate> delegate;

#endif
/**
* An optional short message to be displayed below the activity indicator. The HUD is automatically resized to fit
* the entire text. If the text is too long it will get clipped by displaying "..." at the end. If left unchanged or
Expand Down Expand Up @@ -267,13 +277,19 @@ typedef enum {
/**
* Font to be used for the main label. Set this property if the default is not adequate.
*/
#if __has_feature(objc_arc)
@property (strong) UIFont* labelFont;
#else
@property (retain) UIFont* labelFont;

#endif
/**
* Font to be used for the details label. Set this property if the default is not adequate.
*/
#if __has_feature(objc_arc)
@property (strong) UIFont* detailsLabelFont;
#else
@property (retain) UIFont* detailsLabelFont;

#endif
/**
* The progress of the progress indicator, from 0.0 to 1.0. Defaults to 0.0.
*/
Expand Down
65 changes: 55 additions & 10 deletions MWPhotoBrowser/Libraries/MBProgressHUD/MBProgressHUD.m
Expand Up @@ -19,19 +19,26 @@ - (void)handleGraceTimer:(NSTimer *)theTimer;
- (void)handleMinShowTimer:(NSTimer *)theTimer;
- (void)setTransformForCurrentOrientation:(BOOL)animated;
- (void)cleanUp;
- (void)deviceOrientationDidChange:(NSNotification*)notification;
- (void)launchExecution;
- (void)deviceOrientationDidChange:(NSNotification *)notification;
- (void)hideDelayed:(NSNumber *)animated;
- (void)launchExecution;
- (void)cleanUp;

#if __has_feature(objc_arc)
@property (strong) UIView *indicator;
@property (strong) NSTimer *graceTimer;
@property (strong) NSTimer *minShowTimer;
@property (strong) NSDate *showStarted;
#else
@property (retain) UIView *indicator;
@property (assign) float width;
@property (assign) float height;
@property (retain) NSTimer *graceTimer;
@property (retain) NSTimer *minShowTimer;
@property (retain) NSDate *showStarted;
#endif

@property (assign) float width;
@property (assign) float height;

@end

Expand Down Expand Up @@ -149,14 +156,18 @@ - (float)progress {

- (void)updateLabelText:(NSString *)newText {
if (labelText != newText) {
#if !__has_feature(objc_arc)
[labelText release];
#endif
labelText = [newText copy];
}
}

- (void)updateDetailsLabelText:(NSString *)newText {
if (detailsLabelText != newText) {
#if !__has_feature(objc_arc)
[detailsLabelText release];
#endif
detailsLabelText = [newText copy];
}
}
Expand All @@ -171,13 +182,22 @@ - (void)updateIndicators {
}

if (mode == MBProgressHUDModeDeterminate) {
#if __has_feature(objc_arc)
self.indicator = [[MBRoundProgressView alloc] init];
#else
self.indicator = [[[MBRoundProgressView alloc] init] autorelease];
}
#endif
}
else if (mode == MBProgressHUDModeCustomView && self.customView != nil){
self.indicator = self.customView;
} else {
#if __has_feature(objc_arc)
self.indicator = [[UIActivityIndicatorView alloc]
initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
#else
self.indicator = [[[UIActivityIndicatorView alloc]
initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge] autorelease];
#endif
[(UIActivityIndicatorView *)indicator startAnimating];
}

Expand All @@ -200,7 +220,11 @@ + (MBProgressHUD *)showHUDAddedTo:(UIView *)view animated:(BOOL)animated {
MBProgressHUD *hud = [[MBProgressHUD alloc] initWithView:view];
[view addSubview:hud];
[hud show:animated];
#if __has_feature(objc_arc)
return hud;
#else
return [hud autorelease];
#endif
}

+ (BOOL)hideHUDForView:(UIView *)view animated:(BOOL)animated {
Expand Down Expand Up @@ -245,6 +269,15 @@ - (id)initWithView:(UIView *)view {
return me;
}

- (void)removeFromSuperview {
[[NSNotificationCenter defaultCenter] removeObserver:self
name:UIDeviceOrientationDidChangeNotification
object:nil];

[super removeFromSuperview];
}


- (id)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
Expand Down Expand Up @@ -287,9 +320,8 @@ - (id)initWithFrame:(CGRect)frame {
return self;
}

#if !__has_feature(objc_arc)
- (void)dealloc {
[[NSNotificationCenter defaultCenter] removeObserver:self];

[indicator release];
[label release];
[detailsLabel release];
Expand All @@ -301,6 +333,7 @@ - (void)dealloc {
[customView release];
[super dealloc];
}
#endif

#pragma mark -
#pragma mark Layout
Expand Down Expand Up @@ -462,7 +495,7 @@ - (void)hide:(BOOL)animated {
}

- (void)hide:(BOOL)animated afterDelay:(NSTimeInterval)delay {
[self performSelector:@selector(hideDelayed:) withObject:[NSNumber numberWithBool:delay] afterDelay:delay];
[self performSelector:@selector(hideDelayed:) withObject:[NSNumber numberWithBool:animated] afterDelay:delay];
}

- (void)hideDelayed:(NSNumber *)animated {
Expand All @@ -484,9 +517,14 @@ - (void)handleMinShowTimer:(NSTimer *)theTimer {
- (void)showWhileExecuting:(SEL)method onTarget:(id)target withObject:(id)object animated:(BOOL)animated {

methodForExecution = method;
#if __has_feature(objc_arc)
targetForExecution = target;
objectForExecution = object;
#else
targetForExecution = [target retain];
objectForExecution = [object retain];

#endif

// Launch execution in new thread
taskInProgress = YES;
[NSThread detachNewThreadSelector:@selector(launchExecution) toTarget:self withObject:nil];
Expand All @@ -496,16 +534,21 @@ - (void)showWhileExecuting:(SEL)method onTarget:(id)target withObject:(id)object
}

- (void)launchExecution {
#if !__has_feature(objc_arc)
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];

#endif
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Warc-performSelector-leaks"
// Start executing the requested task
[targetForExecution performSelector:methodForExecution withObject:objectForExecution];
#pragma clang diagnostic pop
// Task completed, update view in main thread (note: view operations should
// be done only in the main thread)
[self performSelectorOnMainThread:@selector(cleanUp) withObject:nil waitUntilDone:NO];

#if !__has_feature(objc_arc)
[pool release];
#endif
}

- (void)animationFinished:(NSString *)animationID finished:(BOOL)finished context:(void*)context {
Expand Down Expand Up @@ -536,8 +579,10 @@ - (void)cleanUp {

self.indicator = nil;

#if !__has_feature(objc_arc)
[targetForExecution release];
[objectForExecution release];
#endif

[self hide:useAnimation];
}
Expand Down
4 changes: 4 additions & 0 deletions MWPhotoBrowser/Libraries/MBProgressHUD/README.mdown
Expand Up @@ -50,6 +50,10 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
Change-log
==========

**Version 0.41** @ 03.01.12

- Support for ARC.

**Version 0.4** @ 25.07.10

- Different animation modes. Default set to zoom.
Expand Down
6 changes: 3 additions & 3 deletions MWPhotoBrowser/MWPhotoBrowser.xcodeproj/project.pbxproj
Expand Up @@ -158,7 +158,7 @@
4C6F96F014AF70E800F8389A /* Libraries */ = {
isa = PBXGroup;
children = (
4C6F96F214AF70FA00F8389A /* MBProgressHUD (f4e551a) */,
4C6F96F214AF70FA00F8389A /* MBProgressHUD (2afc4dd) */,
4C6F96F114AF70F500F8389A /* SDWebImage (8318b29) */,
);
name = Libraries;
Expand Down Expand Up @@ -189,13 +189,13 @@
name = "SDWebImage (8318b29)";
sourceTree = "<group>";
};
4C6F96F214AF70FA00F8389A /* MBProgressHUD (f4e551a) */ = {
4C6F96F214AF70FA00F8389A /* MBProgressHUD (2afc4dd) */ = {
isa = PBXGroup;
children = (
4C6F96F414AF710800F8389A /* MBProgressHUD.h */,
4C6F96F514AF710800F8389A /* MBProgressHUD.m */,
);
name = "MBProgressHUD (f4e551a)";
name = "MBProgressHUD (2afc4dd)";
sourceTree = "<group>";
};
4C6F97E114AF7CCE00F8389A /* Supporting Files */ = {
Expand Down

0 comments on commit aa4fd90

Please sign in to comment.