You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by bo...@apache.org on 2012/01/07 00:52:42 UTC
[8/10] git commit: Optimize enumerations as suggested by @plowman.
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/035ad08c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/tree/035ad08c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/diff/035ad08c
Branch: refs/heads/master
Commit: 035ad08c69f0a150a24589c2604f7e5f0923a36f
Parents: 80d0a0c
Author: Bryce Curtis <cu...@gmail.com>
Authored: Tue Nov 22 14:36:24 2011 -0600
Committer: Joe Bowser <jo...@nitobi.com>
Committed: Fri Nov 25 14:38:08 2011 -0800
----------------------------------------------------------------------
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/035ad08c/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();
}
}
}