You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ma...@apache.org on 2012/03/30 21:32:23 UTC

[2/2] android commit: CB-321: Media API: 'mediaSuccess' callback param to new Media() is called soon after new obj created

CB-321: Media API: 'mediaSuccess' callback param to new Media() is called soon after new obj created


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

Branch: refs/heads/master
Commit: 700ae50e9b2f48088495606e062757ebea46ae8d
Parents: d2b3296
Author: macdonst <si...@gmail.com>
Authored: Fri Mar 30 15:29:26 2012 -0400
Committer: macdonst <si...@gmail.com>
Committed: Fri Mar 30 15:29:26 2012 -0400

----------------------------------------------------------------------
 framework/assets/js/cordova.android.js |   88 ++++++++++++++-------------
 1 files changed, 45 insertions(+), 43 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/700ae50e/framework/assets/js/cordova.android.js
----------------------------------------------------------------------
diff --git a/framework/assets/js/cordova.android.js b/framework/assets/js/cordova.android.js
index 5ab3ac5..ad18513 100644
--- a/framework/assets/js/cordova.android.js
+++ b/framework/assets/js/cordova.android.js
@@ -2901,7 +2901,7 @@ Media.get = function(id) {
  * Start or resume playing audio file.
  */
 Media.prototype.play = function(options) {
-    exec(this.successCallback, this.errorCallback, "Media", "startPlayingAudio", [this.id, this.src, options]);
+    exec(null, null, "Media", "startPlayingAudio", [this.id, this.src, options]);
 };
 
 /**
@@ -3512,8 +3512,9 @@ function Device() {
     this.cordova = null;
 
     var me = this;
-    this.getInfo(
-        function(info) {
+
+    channel.onCordovaReady.subscribeOnce(function() {
+        me.getInfo(function(info) {
             me.available = true;
             me.platform = info.platform;
             me.version = info.version;
@@ -3521,11 +3522,11 @@ function Device() {
             me.uuid = info.uuid;
             me.cordova = info.cordova;
             channel.onCordovaInfoReady.fire();
-        },
-        function(e) {
+        },function(e) {
             me.available = false;
             utils.alert("[ERROR] Error initializing Cordova: " + e);
         });
+    });
 }
 
 /**
@@ -4498,46 +4499,47 @@ var exec = require('cordova/exec'),
     channel = require('cordova/channel');
 
 var NetworkConnection = function () {
-        this.type = null;
-        this._firstRun = true;
-        this._timer = null;
-        this.timeout = 500;
-
-        var me = this;
-
-        this.getInfo(
-            function (info) {
-                me.type = info;
-                if (info === "none") {
-                    // set a timer if still offline at the end of timer send the offline event
-                    me._timer = setTimeout(function(){
-                        cordova.fireDocumentEvent("offline");
-                        me._timer = null;
-                        }, me.timeout);
-                } else {
-                    // If there is a current offline event pending clear it
-                    if (me._timer !== null) {
-                        clearTimeout(me._timer);
-                        me._timer = null;
-                    }
-                    cordova.fireDocumentEvent("online");
-                }
+    this.type = null;
+    this._firstRun = true;
+    this._timer = null;
+    this.timeout = 500;
 
-                // should only fire this once
-                if (me._firstRun) {
-                    me._firstRun = false;
-                    channel.onCordovaConnectionReady.fire();
-                }
-            },
-            function (e) {
-                // If we can't get the network info we should still tell Cordova
-                // to fire the deviceready event.
-                if (me._firstRun) {
-                    me._firstRun = false;
-                    channel.onCordovaConnectionReady.fire();
+    var me = this;
+
+    channel.onCordovaReady.subscribeOnce(function() {
+        me.getInfo(function (info) {
+            me.type = info;
+            if (info === "none") {
+                // set a timer if still offline at the end of timer send the offline event
+                me._timer = setTimeout(function(){
+                    cordova.fireDocumentEvent("offline");
+                    me._timer = null;
+                    }, me.timeout);
+            } else {
+                // If there is a current offline event pending clear it
+                if (me._timer !== null) {
+                    clearTimeout(me._timer);
+                    me._timer = null;
                 }
-                console.log("Error initializing Network Connection: " + e);
-            });
+                cordova.fireDocumentEvent("online");
+            }
+
+            // should only fire this once
+            if (me._firstRun) {
+                me._firstRun = false;
+                channel.onCordovaConnectionReady.fire();
+            }
+        },
+        function (e) {
+            // If we can't get the network info we should still tell Cordova
+            // to fire the deviceready event.
+            if (me._firstRun) {
+                me._firstRun = false;
+                channel.onCordovaConnectionReady.fire();
+            }
+            console.log("Error initializing Network Connection: " + e);
+        });
+    });
 };
 
 /**