Skip to content

Commit

Permalink
Merge pull request #30 from zubinxiong/patch-3
Browse files Browse the repository at this point in the history
修改为 eventbus 3.0 的使用方法,并补充了关于3.0引进的索引加速功能
  • Loading branch information
francistao authored Sep 16, 2016
2 parents fc41991 + 8a2d6e3 commit c924ced
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion Part1/Android/EventBus用法详解.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ eventBus.post(event)
接收消息并处理:

```
public void onEvent(MessageEvent event) {}
// 3.0后不再要求事件以 onEvent 开头,而是采用注解的方式
@Subscribe(threadMode = ThreadMode.MAIN)
public void receive(MessageEvent event){}
```

注销事件接收:
Expand All @@ -72,6 +74,13 @@ public void onEvent(MessageEvent event) {}
eventBus.unregister(this);
```

索引加速:

```
3.0 后引入了索引加速(默认不开启)的功能,即通过 apt 编译插件的方式,在代码编译的时候对注解进行索引,避免了以往通过反射造成的性能损耗。
如何使用可以参考[官方文档](http://greenrobot.org/eventbus/documentation/subscriber-index/)
```

最后,proguard 需要做一些额外处理:

```
Expand Down

0 comments on commit c924ced

Please sign in to comment.