incubator-callback-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bows...@apache.org
Subject [28/50] git commit: Optimize enumerations as suggested by @plowman.
Date Tue, 03 Jan 2012 18:57:09 GMT
Optimize enumerations as suggested by @plowman.


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

Branch: refs/heads/master
Commit: 4a25d780cebc1baaf102358c96b77d9bef1aad0d
Parents: 798cb3e
Author: Bryce Curtis <curtis.bryce@gmail.com>
Authored: Tue Nov 22 14:36:24 2011 -0600
Committer: Bryce Curtis <curtis.bryce@gmail.com>
Committed: Tue Nov 22 14:36:24 2011 -0600

----------------------------------------------------------------------
 framework/src/com/phonegap/AudioHandler.java |   22 ++++++--------------
 1 files changed, 7 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/4a25d780/framework/src/com/phonegap/AudioHandler.java
----------------------------------------------------------------------
diff --git a/framework/src/com/phonegap/AudioHandler.java b/framework/src/com/phonegap/AudioHandler.java
index dc67256..6259496 100755
--- a/framework/src/com/phonegap/AudioHandler.java
+++ b/framework/src/com/phonegap/AudioHandler.java
@@ -130,13 +130,9 @@ public class AudioHandler extends Plugin {
 	 * Stop all audio players and recorders.
 	 */
 	public void onDestroy() {
-		java.util.Set<Entry<String,AudioPlayer>> s = this.players.entrySet();
-        java.util.Iterator<Entry<String,AudioPlayer>> it = s.iterator();
-        while(it.hasNext()) {
-            Entry<String,AudioPlayer> entry = it.next();
-            AudioPlayer audio = entry.getValue();
+        for (AudioPlayer audio : this.players.values()) {
             audio.destroy();
-		}
+        }
         this.players.clear();
 	}
 	
@@ -154,26 +150,22 @@ public class AudioHandler extends Plugin {
             // If phone ringing, then pause playing
             if ("ringing".equals(data) || "offhook".equals(data)) {
                 
-                // Get all audio players and pause then
-                java.util.Set<Entry<String,AudioPlayer>> s = this.players.entrySet();
-                java.util.Iterator<Entry<String,AudioPlayer>> it = s.iterator();
-                while (it.hasNext()) {
-                    Entry<String,AudioPlayer> entry = it.next();
-                    AudioPlayer audio = entry.getValue();
+                // Get all audio players and pause them
+                for (AudioPlayer audio : this.players.values()) {
                     if (audio.getState() == AudioPlayer.MEDIA_RUNNING) {
                         this.pausedForPhone.add(audio);
                         audio.pausePlaying();
                     }
                 }
+
             }
             
             // If phone idle, then resume playing those players we paused
             else if ("idle".equals(data)) {
-                for (int i=0; i<this.pausedForPhone.size(); i++) {
-                    AudioPlayer audio = this.pausedForPhone.get(i);
+                for (AudioPlayer audio : this.pausedForPhone) {
                     audio.startPlaying(null);
                 }
-                this.pausedForPhone = new ArrayList<AudioPlayer>();
+                this.pausedForPhone.clear();
             }
         }
     }


Mime
View raw message