使用:
@Override
protected void onResume() {
super.onResume();
EventPoster.getSingleton().register(this);
}
@Override
protected void onPause() {
super.onPause();
EventPoster.getSingleton().unRegister(this);
}
事件处理器:
@Subscribe(type = 2,target = ThreadMode.WORK_THREAD)
public void onEnventAnnotion2(IEvent event) {
Log.i(TAG,"onEvent,event = " + event + ",Thread = " + Thread.currentThread().getName());
}
发送事件:
EventPoster.getSingleton().post(new EventImpl());
Github 地址:https://github.com/shilec/EventPoster