|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objecttwaver.event.Dispatcher<E>
E
- public class Dispatcher<E extends Event>
事件派发器, IDispatcher
实现类
Constructor Summary | |
---|---|
Dispatcher()
|
Method Summary | |
---|---|
void |
addListener(IListener<E> listener)
添加监听器 |
WeakListener<E> |
addWeakListener(IListener<E> listener)
添加弱引用监听器,将普通监听器包装成弱引用监听器,当监听器不被任何对象引用时,自动从派发器中删除 |
boolean |
beforeEvent(E event)
事件发生前,返回false表示中断事件,用于操作前的检测 |
void |
clear()
清空监听器集合 |
boolean |
fireEvent(E event)
派发事件 |
boolean |
hasListener()
|
void |
onEvent(E event)
事件发生时回调 |
void |
removeListener(IListener<E> listener)
删除监听器 |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Dispatcher()
Method Detail |
---|
public void addListener(IListener<E> listener)
IDispatcher
addListener
in interface IDispatcher<E extends Event>
listener
- 监听器public void removeListener(IListener<E> listener)
IDispatcher
removeListener
in interface IDispatcher<E extends Event>
listener
- 监听器public WeakListener<E> addWeakListener(IListener<E> listener)
IDispatcher
addWeakListener
in interface IDispatcher<E extends Event>
listener
- 监听器
public boolean fireEvent(E event)
IDispatcher
fireEvent
in interface IDispatcher<E extends Event>
event
- 事件
IListener.beforeEvent(Event)
返回false,则中断事件派发,此处也将返回falsepublic void onEvent(E event)
IListener
onEvent
in interface IListener<E extends Event>
event
- 事件public boolean beforeEvent(E event)
IListener
beforeEvent
in interface IListener<E extends Event>
event
- 事件
public void clear()
IDispatcher
clear
in interface IDispatcher<E extends Event>
public boolean hasListener()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |