incubator-callback-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bows...@apache.org
Subject [9/10] git commit: Change API to postMessage() to call a plugin's onMessage() method.
Date Fri, 06 Jan 2012 23:52:42 GMT
Change API to postMessage() to call a plugin's onMessage() method.


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/80d0a0cb
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/tree/80d0a0cb
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/diff/80d0a0cb

Branch: refs/heads/master
Commit: 80d0a0cb4c801e4e5fb2f74534ba9351946b5969
Parents: 05e233b
Author: Bryce Curtis <curtis.bryce@gmail.com>
Authored: Tue Nov 22 14:36:00 2011 -0600
Committer: Joe Bowser <joe.bowser@nitobi.com>
Committed: Fri Nov 25 14:38:07 2011 -0800

----------------------------------------------------------------------
 framework/src/com/phonegap/Device.java             |    6 +-
 framework/src/com/phonegap/DroidGap.java           |   10 ++--
 framework/src/com/phonegap/NetworkManager.java     |    2 +-
 .../src/com/phonegap/api/PhonegapActivity.java     |    2 +-
 framework/src/com/phonegap/api/PluginManager.java  |   48 ++++----------
 5 files changed, 24 insertions(+), 44 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/80d0a0cb/framework/src/com/phonegap/Device.java
----------------------------------------------------------------------
diff --git a/framework/src/com/phonegap/Device.java b/framework/src/com/phonegap/Device.java
index 4202ef6..f752a8d 100755
--- a/framework/src/com/phonegap/Device.java
+++ b/framework/src/com/phonegap/Device.java
@@ -136,15 +136,15 @@ public class Device extends Plugin {
                         String extraData = intent.getStringExtra(TelephonyManager.EXTRA_STATE);
                         if (extraData.equals(TelephonyManager.EXTRA_STATE_RINGING)) {
                             LOG.i(TAG, "Telephone RINGING");
-                            myctx.onMessage("telephone", "ringing");
+                            myctx.postMessage("telephone", "ringing");
                         }
                         else if (extraData.equals(TelephonyManager.EXTRA_STATE_OFFHOOK))
{
                             LOG.i(TAG, "Telephone OFFHOOK");
-                            myctx.onMessage("telephone", "offhook");
+                            myctx.postMessage("telephone", "offhook");
                         }
                         else if (extraData.equals(TelephonyManager.EXTRA_STATE_IDLE)) {
                             LOG.i(TAG, "Telephone IDLE");
-                            myctx.onMessage("telephone", "idle");
+                            myctx.postMessage("telephone", "idle");
                         }
                     }
                 }

http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/80d0a0cb/framework/src/com/phonegap/DroidGap.java
----------------------------------------------------------------------
diff --git a/framework/src/com/phonegap/DroidGap.java b/framework/src/com/phonegap/DroidGap.java
index 812cb0e..97c62b3 100755
--- a/framework/src/com/phonegap/DroidGap.java
+++ b/framework/src/com/phonegap/DroidGap.java
@@ -840,10 +840,10 @@ public class DroidGap extends PhonegapActivity {
      * @param id            The message id
      * @param data          The message data
      */
-    public void onMessage(String id, Object data) {
+    public void postMessage(String id, Object data) {
         
         // Forward to plugins
-        this.pluginManager.onMessage(id, data);
+        this.pluginManager.postMessage(id, data);
     }
 
     /**
@@ -1835,21 +1835,21 @@ public class DroidGap extends PhonegapActivity {
     @Override
     public boolean onCreateOptionsMenu(Menu menu)
     {
-        this.onMessage("onCreateOptionsMenu", menu);
+        this.postMessage("onCreateOptionsMenu", menu);
         return super.onCreateOptionsMenu(menu);
     }
     
     @Override
     public boolean onPrepareOptionsMenu(Menu menu)
     {
-        this.onMessage("onPrepareOptionsMenu", menu);
+        this.postMessage("onPrepareOptionsMenu", menu);
         return super.onPrepareOptionsMenu(menu);
     }
     
     @Override
     public boolean onOptionsItemSelected(MenuItem item)
     {
-        this.onMessage("onOptionsItemSelected", item);
+        this.postMessage("onOptionsItemSelected", item);
         return true;
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/80d0a0cb/framework/src/com/phonegap/NetworkManager.java
----------------------------------------------------------------------
diff --git a/framework/src/com/phonegap/NetworkManager.java b/framework/src/com/phonegap/NetworkManager.java
index aadac66..2be55d1 100755
--- a/framework/src/com/phonegap/NetworkManager.java
+++ b/framework/src/com/phonegap/NetworkManager.java
@@ -201,7 +201,7 @@ public class NetworkManager extends Plugin {
         this.success(result, this.connectionCallbackId);
         
         // Send to all plugins
-        this.ctx.onMessage("networkconnection", type);
+        this.ctx.postMessage("networkconnection", type);
     }
     
     /**

http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/80d0a0cb/framework/src/com/phonegap/api/PhonegapActivity.java
----------------------------------------------------------------------
diff --git a/framework/src/com/phonegap/api/PhonegapActivity.java b/framework/src/com/phonegap/api/PhonegapActivity.java
index fc5f5e2..cb3c871 100755
--- a/framework/src/com/phonegap/api/PhonegapActivity.java
+++ b/framework/src/com/phonegap/api/PhonegapActivity.java
@@ -76,5 +76,5 @@ public abstract class PhonegapActivity extends Activity {
      * @param id            The message id
      * @param data          The message data
      */
-    abstract public void onMessage(String id, Object data);
+    abstract public void postMessage(String id, Object data);
 }

http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/80d0a0cb/framework/src/com/phonegap/api/PluginManager.java
----------------------------------------------------------------------
diff --git a/framework/src/com/phonegap/api/PluginManager.java b/framework/src/com/phonegap/api/PluginManager.java
index db10d63..6bf9f66 100755
--- a/framework/src/com/phonegap/api/PluginManager.java
+++ b/framework/src/com/phonegap/api/PluginManager.java
@@ -287,13 +287,9 @@ public final class PluginManager {
      * @param multitasking		Flag indicating if multitasking is turned on for app
      */
     public void onPause(boolean multitasking) {
-    	java.util.Set<Entry<String,IPlugin>> s = this.plugins.entrySet();
-    	java.util.Iterator<Entry<String,IPlugin>> it = s.iterator();
-    	while(it.hasNext()) {
-    		Entry<String,IPlugin> entry = it.next();
-    		IPlugin plugin = entry.getValue();
-    		plugin.onPause(multitasking);
-    	}
+        for (IPlugin plugin : this.plugins.values()) {
+            plugin.onPause(multitasking);
+        }
     }
     
     /**
@@ -302,26 +298,18 @@ public final class PluginManager {
      * @param multitasking		Flag indicating if multitasking is turned on for app
      */
     public void onResume(boolean multitasking) {
-    	java.util.Set<Entry<String,IPlugin>> s = this.plugins.entrySet();
-    	java.util.Iterator<Entry<String,IPlugin>> it = s.iterator();
-    	while(it.hasNext()) {
-    		Entry<String,IPlugin> entry = it.next();
-    		IPlugin plugin = entry.getValue();
-    		plugin.onResume(multitasking);
-    	}    	
+        for (IPlugin plugin : this.plugins.values()) {
+            plugin.onResume(multitasking);
+        }
     }
 
     /**
      * The final call you receive before your activity is destroyed. 
      */
     public void onDestroy() {
-    	java.util.Set<Entry<String,IPlugin>> s = this.plugins.entrySet();
-    	java.util.Iterator<Entry<String,IPlugin>> it = s.iterator();
-    	while(it.hasNext()) {
-    		Entry<String,IPlugin> entry = it.next();
-    		IPlugin plugin = entry.getValue();
-    		plugin.onDestroy();
-    	}
+        for (IPlugin plugin : this.plugins.values()) {
+            plugin.onDestroy();
+        }
     }
 
     /**
@@ -330,12 +318,8 @@ public final class PluginManager {
      * @param id            The message id
      * @param data          The message data
      */
-    public void onMessage(String id, Object data) {
-        java.util.Set<Entry<String,IPlugin>> s = this.plugins.entrySet();
-        java.util.Iterator<Entry<String,IPlugin>> it = s.iterator();
-        while(it.hasNext()) {
-            Entry<String,IPlugin> entry = it.next();
-            IPlugin plugin = entry.getValue();
+    public void postMessage(String id, Object data) {
+        for (IPlugin plugin : this.plugins.values()) {
             plugin.onMessage(id, data);
         }
     }
@@ -344,13 +328,9 @@ public final class PluginManager {
      * Called when the activity receives a new intent. 
      */    
     public void onNewIntent(Intent intent) {
-    	java.util.Set<Entry<String,IPlugin>> s = this.plugins.entrySet();
-    	java.util.Iterator<Entry<String,IPlugin>> it = s.iterator();
-    	while(it.hasNext()) {
-    		Entry<String,IPlugin> entry = it.next();
-    		IPlugin plugin = entry.getValue();
-    		plugin.onNewIntent(intent);
-    	}
+        for (IPlugin plugin : this.plugins.values()) {
+            plugin.onNewIntent(intent);
+        }
     }
 
     /**


Mime
View raw message