mirror of
https://github.com/apache/cordova-android.git
synced 2025-02-26 20:33:07 +08:00
Optimize enumerations as suggested by @plowman.
This commit is contained in:
parent
80d0a0cb4c
commit
035ad08c69
@ -130,13 +130,9 @@ public class AudioHandler extends Plugin {
|
|||||||
* Stop all audio players and recorders.
|
* Stop all audio players and recorders.
|
||||||
*/
|
*/
|
||||||
public void onDestroy() {
|
public void onDestroy() {
|
||||||
java.util.Set<Entry<String,AudioPlayer>> s = this.players.entrySet();
|
for (AudioPlayer audio : this.players.values()) {
|
||||||
java.util.Iterator<Entry<String,AudioPlayer>> it = s.iterator();
|
|
||||||
while(it.hasNext()) {
|
|
||||||
Entry<String,AudioPlayer> entry = it.next();
|
|
||||||
AudioPlayer audio = entry.getValue();
|
|
||||||
audio.destroy();
|
audio.destroy();
|
||||||
}
|
}
|
||||||
this.players.clear();
|
this.players.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -154,26 +150,22 @@ public class AudioHandler extends Plugin {
|
|||||||
// If phone ringing, then pause playing
|
// If phone ringing, then pause playing
|
||||||
if ("ringing".equals(data) || "offhook".equals(data)) {
|
if ("ringing".equals(data) || "offhook".equals(data)) {
|
||||||
|
|
||||||
// Get all audio players and pause then
|
// Get all audio players and pause them
|
||||||
java.util.Set<Entry<String,AudioPlayer>> s = this.players.entrySet();
|
for (AudioPlayer audio : this.players.values()) {
|
||||||
java.util.Iterator<Entry<String,AudioPlayer>> it = s.iterator();
|
|
||||||
while (it.hasNext()) {
|
|
||||||
Entry<String,AudioPlayer> entry = it.next();
|
|
||||||
AudioPlayer audio = entry.getValue();
|
|
||||||
if (audio.getState() == AudioPlayer.MEDIA_RUNNING) {
|
if (audio.getState() == AudioPlayer.MEDIA_RUNNING) {
|
||||||
this.pausedForPhone.add(audio);
|
this.pausedForPhone.add(audio);
|
||||||
audio.pausePlaying();
|
audio.pausePlaying();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// If phone idle, then resume playing those players we paused
|
// If phone idle, then resume playing those players we paused
|
||||||
else if ("idle".equals(data)) {
|
else if ("idle".equals(data)) {
|
||||||
for (int i=0; i<this.pausedForPhone.size(); i++) {
|
for (AudioPlayer audio : this.pausedForPhone) {
|
||||||
AudioPlayer audio = this.pausedForPhone.get(i);
|
|
||||||
audio.startPlaying(null);
|
audio.startPlaying(null);
|
||||||
}
|
}
|
||||||
this.pausedForPhone = new ArrayList<AudioPlayer>();
|
this.pausedForPhone.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user