Skip to content

Commit

Permalink
[IOL] (Hopefully) fix #4
Browse files Browse the repository at this point in the history
  • Loading branch information
francesco-romano committed Sep 24, 2015
1 parent 11067d4 commit 29ddc6b
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 19 deletions.
4 changes: 2 additions & 2 deletions apps/IOL/IOL/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="8191" systemVersion="14F27" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="49e-Tb-3d3">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="8191" systemVersion="14F27" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="Scd-OB-Hix">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="8154"/>
Expand Down Expand Up @@ -538,7 +538,7 @@
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="gok-jM-Vqy" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="-764" y="6"/>
<point key="canvasLocation" x="-764" y="-302"/>
</scene>
</scenes>
<resources>
Expand Down
33 changes: 23 additions & 10 deletions apps/IOL/IOL/IITAppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,15 @@ + (void)initialize

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
IITInitialViewController *viewController = [storyboard instantiateViewControllerWithIdentifier:@"InitializationView"];
//get initial view controller
IITInitialViewController *viewController = (IITInitialViewController*)self.window.rootViewController;
viewController.delegate = self;

[self.window makeKeyAndVisible];
dispatch_async(dispatch_get_main_queue(), ^{
[self.window.rootViewController presentViewController:viewController animated:YES completion:NULL];
});

// dispatch_async(dispatch_get_main_queue(), ^{
// [self.window.rootViewController presentViewController:viewController animated:YES completion:NULL];
// });
return YES;
}

Expand All @@ -53,20 +54,32 @@ - (void)viewController:(UIViewController *)viewController didCheckNetworkWithRes
preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action) {
[viewController dismissViewControllerAnimated:YES completion:^{
[(UITabBarController*)self.window.rootViewController setSelectedIndex:2
]; }];
[self showTabBarControllerWithSelectedView:3];
}];

[alert addAction:defaultAction];
[viewController presentViewController:alert animated:YES completion:nil];

}
else {
[viewController dismissViewControllerAnimated:YES completion:^{
// [viewController dismissViewControllerAnimated:YES completion:^{
//
// }];
[self showTabBarControllerWithSelectedView:0];
}
}

}];
- (void)showTabBarControllerWithSelectedView:(NSUInteger)index
{
if (![self.window.rootViewController isKindOfClass:[UITabBarController class]])
{
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
self.window.rootViewController = [storyboard instantiateViewControllerWithIdentifier:@"ApplicationMainUI"];
}
UITabBarController* tabController = (UITabBarController*)self.window.rootViewController;
if (index < [tabController.viewControllers count])
[tabController setSelectedViewController:[tabController.viewControllers objectAtIndex:index]];

}

- (void)applicationWillResignActive:(UIApplication *)application {
Expand Down
2 changes: 0 additions & 2 deletions apps/IOL/IOL/ViewControllers/IITGoogleSpeakViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ @implementation IITGoogleSpeakViewController
- (void)viewDidLoad {

[super viewDidLoad];
[self.outputPort isOpen];

// Do any additional setup after loading the view.
self.speechRecognizer = [[IITSpeechRecognizer alloc] init];
self.speechRecognizer.apiKey = @"";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ - (void)setUITabEnable:(BOOL)enable

- (IBAction)dismissKeyboard:(id)sender
{
NSLog(@"dismissing");
[self.yarpServerNamespace endEditing:YES];
[self.yarpServerHost endEditing:YES];
[self.yarpServerPort endEditing:YES];
Expand Down
24 changes: 20 additions & 4 deletions libs/yarp_iOS/yarp_iOS/Utilities/IITYarpNetworkConfiguration.mm
Original file line number Diff line number Diff line change
Expand Up @@ -110,22 +110,35 @@ - (void)initializeNetworkWithTimeout:(double)timeout completionHandler:(void (^)
{
using namespace yarp::os;
if (![[self nameSpace] length]) {
if (completionHandler) completionHandler(NO);
if (completionHandler)
dispatch_async(dispatch_get_main_queue(), ^{
completionHandler(NO);
});

}

Network::init();

__block BOOL check = NO;
__block BOOL finished = NO;
NSOperation *operation = [NSBlockOperation blockOperationWithBlock:^{

NSBlockOperation *operation = [[NSBlockOperation alloc] init];
__weak NSOperation *weakOperation = operation;
[operation addExecutionBlock:^{
check = Network::checkNetwork();
//if operation has been canceled, it means that the callback has already been called
if (weakOperation.isCancelled) return;

finished = YES;
if (!check) {
Network::fini();
} else {
self.initialize = YES;
}
if (completionHandler) completionHandler(check ? YES : NO);
if (completionHandler)
dispatch_async(dispatch_get_main_queue(), ^{
completionHandler(check ? YES : NO);
});
}];

NSOperationQueue *queue = [[NSOperationQueue alloc] init];
Expand All @@ -136,7 +149,10 @@ - (void)initializeNetworkWithTimeout:(double)timeout completionHandler:(void (^)
if (!finished) {
[operation cancel];
Network::fini();
if (completionHandler) completionHandler(check ? YES : NO);
if (completionHandler)
dispatch_async(dispatch_get_main_queue(), ^{
completionHandler(check ? YES : NO);
});
}
});
}
Expand Down

0 comments on commit 29ddc6b

Please sign in to comment.