now show loading frame when waiting for background tasks

This commit is contained in:
Diego Waxemberg
2015-02-24 22:33:14 -05:00
parent 3617ea98e2
commit 65f7e75736
5 changed files with 13 additions and 2 deletions
@@ -9,6 +9,6 @@
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
@interface LoadingFrameViewController : UIViewController @interface LoadingFrameViewController : UIViewController
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *loadingSpinner;
@property (weak, nonatomic) IBOutlet UIActivityIndicatorView *loadingSpinner;
@end @end
@@ -16,6 +16,8 @@
- (void)viewDidLoad { - (void)viewDidLoad {
[super viewDidLoad]; [super viewDidLoad];
// center the loading spinner
self.loadingSpinner.center = CGPointMake(self.view.frame.size.width / 2, self.view.frame.size.height / 2);
} }
- (void)didReceiveMemoryWarning { - (void)didReceiveMemoryWarning {
@@ -52,6 +52,7 @@ static NSArray* appList;
_pairAlert = [[UIAlertView alloc] initWithTitle:@"Pairing Failed" message:message delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil]; _pairAlert = [[UIAlertView alloc] initWithTitle:@"Pairing Failed" message:message delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil];
[_pairAlert show]; [_pairAlert show];
[_discMan startDiscovery]; [_discMan startDiscovery];
[self hideLoadingFrame];
}); });
} }
@@ -61,6 +62,7 @@ static NSArray* appList;
_pairAlert = [[UIAlertView alloc] initWithTitle:@"Pairing Succesful" message:@"Successfully paired to host" delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil]; _pairAlert = [[UIAlertView alloc] initWithTitle:@"Pairing Succesful" message:@"Successfully paired to host" delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil];
[_pairAlert show]; [_pairAlert show];
[_discMan startDiscovery]; [_discMan startDiscovery];
[self hideLoadingFrame];
}); });
} }
@@ -83,6 +85,7 @@ static NSArray* appList;
} else { } else {
dispatch_async(dispatch_get_main_queue(), ^{ dispatch_async(dispatch_get_main_queue(), ^{
[self updateApps]; [self updateApps];
[self hideLoadingFrame];
}); });
[_appManager stopRetrieving]; [_appManager stopRetrieving];
@@ -114,6 +117,7 @@ static NSArray* appList;
- (void) hostClicked:(Host *)host { - (void) hostClicked:(Host *)host {
Log(LOG_D, @"Clicked host: %@", host.name); Log(LOG_D, @"Clicked host: %@", host.name);
[self showLoadingFrame];
_selectedHost = host; _selectedHost = host;
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
HttpManager* hMan = [[HttpManager alloc] initWithHost:host.address uniqueId:_uniqueId deviceName:deviceName cert:_cert]; HttpManager* hMan = [[HttpManager alloc] initWithHost:host.address uniqueId:_uniqueId deviceName:deviceName cert:_cert];
@@ -187,6 +191,7 @@ static NSArray* appList;
- (void) addHostClicked { - (void) addHostClicked {
Log(LOG_D, @"Clicked add host"); Log(LOG_D, @"Clicked add host");
[self showLoadingFrame];
UIAlertController* alertController = [UIAlertController alertControllerWithTitle:@"Host Address" message:@"Please enter a hostname or IP address" preferredStyle:UIAlertControllerStyleAlert]; UIAlertController* alertController = [UIAlertController alertControllerWithTitle:@"Host Address" message:@"Please enter a hostname or IP address" preferredStyle:UIAlertControllerStyleAlert];
[alertController addAction:[UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:nil]]; [alertController addAction:[UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:nil]];
[alertController addAction:[UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction* action){ [alertController addAction:[UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction* action){
@@ -212,6 +217,7 @@ static NSArray* appList;
}];}); }];});
}]]; }]];
[alertController addTextFieldWithConfigurationHandler:nil]; [alertController addTextFieldWithConfigurationHandler:nil];
[self hideLoadingFrame];
[self presentViewController:alertController animated:YES completion:nil]; [self presentViewController:alertController animated:YES completion:nil];
} }
+3
View File
@@ -242,6 +242,9 @@
<color key="backgroundColor" white="0.0" alpha="0.5" colorSpace="calibratedWhite"/> <color key="backgroundColor" white="0.0" alpha="0.5" colorSpace="calibratedWhite"/>
</view> </view>
<simulatedOrientationMetrics key="simulatedOrientationMetrics" orientation="landscapeRight"/> <simulatedOrientationMetrics key="simulatedOrientationMetrics" orientation="landscapeRight"/>
<connections>
<outlet property="loadingSpinner" destination="N0D-dj-EuF" id="xEQ-nx-SOt"/>
</connections>
</viewController> </viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="lJG-tq-Jrs" userLabel="First Responder" sceneMemberID="firstResponder"/> <placeholder placeholderIdentifier="IBFirstResponder" id="lJG-tq-Jrs" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects> </objects>
+1 -1
View File
@@ -245,7 +245,7 @@
</view> </view>
<simulatedOrientationMetrics key="simulatedOrientationMetrics" orientation="landscapeRight"/> <simulatedOrientationMetrics key="simulatedOrientationMetrics" orientation="landscapeRight"/>
<connections> <connections>
<outlet property="loadingSpinner" destination="jJs-wm-fmH" id="Qq1-JJ-55a"/> <outlet property="loadingSpinner" destination="oNu-Gu-QeM" id="5IK-qn-mIZ"/>
</connections> </connections>
</viewController> </viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="GaV-PK-JSI" userLabel="First Responder" sceneMemberID="firstResponder"/> <placeholder placeholderIdentifier="IBFirstResponder" id="GaV-PK-JSI" userLabel="First Responder" sceneMemberID="firstResponder"/>