cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mmo...@apache.org
Subject ios commit: [ios] Fix resign/pause event
Date Tue, 30 Oct 2012 15:19:36 GMT
Updated Branches:
  refs/heads/master 2792e7a41 -> e545a4ba9


[ios] Fix resign/pause event


Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/commit/e545a4ba
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/tree/e545a4ba
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/diff/e545a4ba

Branch: refs/heads/master
Commit: e545a4ba974a543fe02b9e3c0ac11c95c9645404
Parents: 2792e7a
Author: Michal Mocny <mmocny@gmail.com>
Authored: Tue Oct 30 09:36:34 2012 -0400
Committer: Michal Mocny <mmocny@gmail.com>
Committed: Tue Oct 30 11:19:57 2012 -0400

----------------------------------------------------------------------
 CordovaLib/Classes/CDVCommandDelegate.h     |    1 +
 CordovaLib/Classes/CDVCommandDelegateImpl.m |   11 ++++++++++-
 CordovaLib/Classes/CDVViewController.m      |    4 ++--
 3 files changed, 13 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/e545a4ba/CordovaLib/Classes/CDVCommandDelegate.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVCommandDelegate.h b/CordovaLib/Classes/CDVCommandDelegate.h
index bd793b5..5edb39c 100644
--- a/CordovaLib/Classes/CDVCommandDelegate.h
+++ b/CordovaLib/Classes/CDVCommandDelegate.h
@@ -37,6 +37,7 @@
 - (void)sendPluginResult:(CDVPluginResult*)result callbackId:(NSString*)callbackId;
 // Evaluates the given JS.
 - (void)evalJs:(NSString*)js;
+- (void)evalJs:(NSString*)js scheduledOnRunLoop:(BOOL)scheduledOnRunLoop;
 // Runs the given block on a background thread.
 - (void)runInBackground:(void (^)())block;
 

http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/e545a4ba/CordovaLib/Classes/CDVCommandDelegateImpl.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVCommandDelegateImpl.m b/CordovaLib/Classes/CDVCommandDelegateImpl.m
index 2cdf85f..76413bd 100644
--- a/CordovaLib/Classes/CDVCommandDelegateImpl.m
+++ b/CordovaLib/Classes/CDVCommandDelegateImpl.m
@@ -95,8 +95,17 @@
 
 - (void)evalJs:(NSString*)js
 {
+    [self evalJs:js scheduledOnRunLoop:YES];
+}
+
+- (void)evalJs:(NSString*)js scheduledOnRunLoop:(BOOL)scheduledOnRunLoop
+{
     js = [NSString stringWithFormat:@"cordova.require('cordova/exec').nativeEvalAndFetch(function(){%@})",
js];
-    [self evalJsHelper:js];
+    if (scheduledOnRunLoop) {
+        [self evalJsHelper:js];
+    } else {
+        [self evalJsHelper2:js];
+    }
 }
 
 - (BOOL)execute:(CDVInvokedUrlCommand*)command

http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/e545a4ba/CordovaLib/Classes/CDVViewController.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVViewController.m b/CordovaLib/Classes/CDVViewController.m
index 3e31fd9..a47d649 100644
--- a/CordovaLib/Classes/CDVViewController.m
+++ b/CordovaLib/Classes/CDVViewController.m
@@ -877,7 +877,7 @@ BOOL gSplashScreenShown = NO;
 - (void)onAppWillResignActive:(NSNotification*)notification
 {
     // NSLog(@"%@",@"applicationWillResignActive");
-    [self.commandDelegate evalJs:@"cordova.fireDocumentEvent('resign');"];
+    [self.commandDelegate evalJs:@"cordova.fireDocumentEvent('resign');" scheduledOnRunLoop:NO];
 }
 
 /*
@@ -905,7 +905,7 @@ BOOL gSplashScreenShown = NO;
 - (void)onAppDidEnterBackground:(NSNotification*)notification
 {
     // NSLog(@"%@",@"applicationDidEnterBackground");
-    [self.commandDelegate evalJs:@"cordova.fireDocumentEvent('pause');"];
+    [self.commandDelegate evalJs:@"cordova.fireDocumentEvent('pause', null, true);" scheduledOnRunLoop:NO];
 }
 
 // ///////////////////////


Mime
View raw message