cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From purplecabb...@apache.org
Subject [2/2] cordova-plugin-dialogs git commit: CB-9347 - fix to allow to stack multiple UIAlertControllers
Date Tue, 20 Oct 2015 00:16:11 GMT
CB-9347 - fix to allow to stack multiple UIAlertControllers

Deleted the 0,5 seconds delay, now it presents the next
UIAlertController (if any) on the presentViewController completion
block


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs/commit/7fd94a1f
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs/tree/7fd94a1f
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs/diff/7fd94a1f

Branch: refs/heads/master
Commit: 7fd94a1f337433c956b9d21d57e89ee64c1be65e
Parents: 98d3e90
Author: Julio César <jcesarmobile@gmail.com>
Authored: Fri Jul 17 17:04:04 2015 +0200
Committer: Julio César <jcesarmobile@gmail.com>
Committed: Fri Jul 17 17:04:04 2015 +0200

----------------------------------------------------------------------
 src/ios/CDVNotification.m | 34 ++++++++++++++++++++++------------
 1 file changed, 22 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs/blob/7fd94a1f/src/ios/CDVNotification.m
----------------------------------------------------------------------
diff --git a/src/ios/CDVNotification.m b/src/ios/CDVNotification.m
index f96d0d5..b10cb03 100644
--- a/src/ios/CDVNotification.m
+++ b/src/ios/CDVNotification.m
@@ -98,19 +98,10 @@ static NSMutableArray *alertList = nil;
         if(!alertList)
             alertList = [[NSMutableArray alloc] init];
         [alertList addObject:alertController];
-        dispatch_time_t delay = dispatch_time(DISPATCH_TIME_NOW, NSEC_PER_SEC * ([alertList
count]-1)/2);
         
-        dispatch_after(delay, dispatch_get_main_queue(), ^(void){
-            
-            UIViewController *presentingViewController = self.viewController;
-            while(presentingViewController.presentedViewController != nil)
-            {
-                presentingViewController = presentingViewController.presentedViewController;
-            }
-            [presentingViewController presentViewController:alertController animated:YES
completion:^{
-                [alertList removeObject:alertController];
-            }];
-        });
+        if ([alertList count]==1) {
+            [self presentAlertcontroller];
+        }
         
     } else {
 #endif
@@ -225,6 +216,25 @@ static void soundCompletionCallback(SystemSoundID  ssid, void* data)
{
     playBeep([count intValue]);
 }
 
+-(UIViewController *)getTopPresentedViewController {
+    UIViewController *presentingViewController = self.viewController;
+    while(presentingViewController.presentedViewController != nil)
+    {
+        presentingViewController = presentingViewController.presentedViewController;
+    }
+    return presentingViewController;
+}
+
+-(void)presentAlertcontroller {
+    
+    [self.getTopPresentedViewController presentViewController:[alertList firstObject] animated:YES
completion:^{
+        [alertList removeObject:[alertList firstObject]];
+        if ([alertList count]>0) {
+            [self presentAlertcontroller];
+        }
+    }];
+    
+}
 
 @end
 


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org


Mime
View raw message