fix: record isn't stopped when volume down
refactor: recorder
This commit is contained in:
32
common/src/main/java/com/stardust/event/EventDispatcher.java
Normal file
32
common/src/main/java/com/stardust/event/EventDispatcher.java
Normal file
@@ -0,0 +1,32 @@
|
||||
package com.stardust.event;
|
||||
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
/**
|
||||
* Created by Stardust on 2017/8/6.
|
||||
*/
|
||||
|
||||
public class EventDispatcher<Listener> {
|
||||
|
||||
public interface Event<Listener> {
|
||||
void notify(Listener l);
|
||||
}
|
||||
|
||||
private CopyOnWriteArrayList<Listener> mListeners = new CopyOnWriteArrayList<>();
|
||||
|
||||
public void addListener(Listener l) {
|
||||
mListeners.add(l);
|
||||
}
|
||||
|
||||
|
||||
public boolean removeListener(Listener l) {
|
||||
return mListeners.remove(l);
|
||||
}
|
||||
|
||||
public void dispatchEvent(Event<Listener> event) {
|
||||
for (Listener listener : mListeners) {
|
||||
event.notify(listener);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user