Skip to content

Commit c775d23

Browse files
committed
更新readme
2 parents 210a458 + 4fed8e3 commit c775d23

File tree

2 files changed

+44
-21
lines changed

2 files changed

+44
-21
lines changed

README-ch.md

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,15 @@
77
****A english readme is here [README-en.md](README-en.md).****
88

99
## 基本结构
10-
![结构图](http://img.blog.csdn.net/20150203125508110)
10+
![结构图](http://img.blog.csdn.net/20150426223040789)
1111
AndroidEventBus类似于观察者模式,通过register函数将需要订阅事件的对象注册到事件总线中,然后根据@Subscriber注解来查找对象中的订阅方法,并且将这些订阅方法和订阅对象存储在map中。当用户在某个地方发布一个事件时,事件总线根据事件的参数类型和tag找到对应的订阅者对象,最后执行订阅者对象中的方法。这些订阅方法会执行在用户指定的线程模型中,比如mode=ThreadMode.ASYNC则表示该订阅方法执行在子线程中,更多细节请看下面的说明。
1212

1313
## 使用AndroidEventBus
1414
你可以按照下面几个步骤来使用AndroidEventBus.
1515

16-
* 1. 注册事件接收对象
16+
* 1. 注册事件接收对象
1717

1818
```
19-
2019
public class YourActivity extends Activity {
2120
2221
@Override
@@ -103,7 +102,7 @@ public class YourActivity extends Activity {
103102

104103
## 集成
105104
### jar文件集成
106-
将jar文件添加到工程中的引用中即可,[AndroidEventBus.jar下载](lib/androideventbus-1.0.2.jar?raw=true "点击下载到本地")
105+
将jar文件添加到工程中的引用中即可,[AndroidEventBus.jar下载](lib/androideventbus-1.0.3.jar?raw=true "点击下载到本地")
107106

108107
### Android Studio集成
109108
* 在Project的build.gradle中添加仓库地址
@@ -122,9 +121,9 @@ allprojects {
122121
```
123122
dependencies {
124123
compile fileTree(dir: 'libs', include: ['*.jar'])
125-
compile 'com.android.support:appcompat-v7:21.0.3'
124+
126125
// 添加依赖
127-
compile 'org.simple:androideventbus:1.0.2'
126+
compile 'org.simple:androideventbus:latest'
128127
}
129128
```
130129
@@ -146,14 +145,25 @@ private void onEventMainThread(User aUser) {
146145
### 与EventBus、otto的特性对比
147146

148147
| 名称 | 订阅函数是否可执行在其他线程 | 特点 |
149-
|---------------------|-----------------------|
150-
| [greenrobot的EventBus](https://github.com/greenrobot/EventBus) | 是 | 使用name pattern模式,效率高,但使用不方便。
151-
| [square的otto](https://github.com/square/otto) | 否 | 使用注解,使用方便,但效率比不了EventBus。
148+
|---------------------|-----------------------|---------------------------------|
149+
| [greenrobot的EventBus](https://github.com/greenrobot/EventBus) || 使用name pattern模式,效率高,但使用不方便。|
150+
| [square的otto](https://github.com/square/otto) || 使用注解,使用方便,但效率比不了EventBus。 |
152151
| [AndroidEventBus]() || 使用注解,使用方便,但效率比不上EventBus。订阅函数支持tag(类似广播接收器的Action)使得事件的投递更加准确,能适应更多使用场景。 |
153152

154153

154+
## 混淆配置
155+
156+
```
157+
-keep class org.simple.** { *; }
158+
-keep interface org.simple.** { *; }
159+
-keepclassmembers class * {
160+
@org.simple.eventbus.Subscriber <methods>;
161+
}
162+
```
163+
155164
## 使用了AndroidEventBus的已知App
156165
* [Accupass - Events around you](https://play.google.com/store/apps/details?id=com.accuvally.android.accupass)
166+
* [考拉FM](http://www.wandoujia.com/apps/com.itings.myradio)
157167

158168
`欢迎大家给我反馈使用情况`
159169

@@ -164,6 +174,11 @@ private void onEventMainThread(User aUser) {
164174

165175
166176
## 发布历史
177+
178+
### V1.0.3 ( 2015.5.23 )
179+
1. 支持Sticky事件。
180+
181+
167182
### V1.0.2 ( 2015.2.28 )
168183
1. 修复订阅方法的参数是基本类型( int, boolean等 )不能接收事件的问题。
169184

README.md

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ This is an EventBus library for Android. It simplifies the communication between
55
****中文版 [README.md](README-ch.md).****
66

77
## Basic Architecture
8-
![arch](http://img.blog.csdn.net/20150203125508110)
8+
![arch](http://img.blog.csdn.net/20150426223040789)
99

1010
AndroidEventBus is like the Observer Pattern. It will have the objects which need to subscribe events registered into the EventBus through Function “register” and store such subscription methods and subscription objects in Map. When a user posts an event somewhere, the EventBus will find corresponding subscription object in accordance with the parameter type and tag of the Event and then execute the method in subscription object. These subscription methods will be executed in the Thread Mode designated by the user. For example, mode=ThreadMode. ASNYC means the subscription method is executed in the sub-thread. Please refer to the following instructions for more details.
1111

@@ -40,7 +40,6 @@ public class YourActivity extends Activity {
4040
* 2. Mark the receiving method of the Event-receiving Object with Subscriber annotation.
4141

4242
```
43-
4443
public class YourActivity extends Activity {
4544
4645
// code ......
@@ -143,27 +142,37 @@ private void onEventMainThread(User aUser) {
143142
```
144143

145144
If there are two receiving functions of the same parameter type and both are executed on the main thread, how to name them distinctively? Supposing that there are two functions meeting the requirements and the event is adding user, but because the EventBus judges receiving function only by parameter type of the event, both function will be executed. The strategy of AndroidEventBus is to add a “tag” for each event, and use parameter type and “tag” to jointly mark the uniqueness of the vent so as to ensure precise delivery.
146-
These are the differences between AndroidEventBus and EventBus of greenrobot. But it is understandable for greenrobot’s approach considering performance. And what I try to express is that there are very limited quantity of events posted in an App and the performance difference is negligible while user experience is well sensible. What I need to point out is that I know little about the ins and outs of EventsBus of greenrobot and there could be errors among what I’ve mentioned. If that happens, you are more than welcome to correct me.
147145

148-
### Comparison Of Characteristics
146+
These are the differences between AndroidEventBus and EventBus of greenrobot. But it is understandable for greenrobot’s approach considering performance. And what I try to express is that there are very limited quantity of events posted in an App and the performance difference is negligible while user experience is well sensible. What I need to point out is that I know little about the ins and outs of EventsBus of greenrobot and there could be errors among what I’ve mentioned. If that happens, you are more than welcome to correct me.
147+
148+
149+
### Comparison Of Characteristics
149150

150151
| library | Whether the subscription function can be executed on other thread | features |
151152
|---------------------|-----------------------|------------------|
152153
| [greenrobot's EventBus](https://github.com/greenrobot/EventBus) | yes | It adopts name pattern which is efficient but inconvenient to use. |
153154
| [square's otto](https://github.com/square/otto) | no | It is convenient to use annotation but it’s not as efficient as EventBus|
154-
| [AndroidEventBus]() | yes | It is convenient to use annotation but it’s not as efficient as EventBus. The subscription supports tag (like the Action in Broadcast Receiver) which can make event delivery more accurate and applicable to more usage scenarios. | ## AndroidEventBus is adopted in the following app
155-
* [Accupass - Events around you](https://play.google.com/store/apps/details?id=com.accuvally.android.accupass)
155+
| [AndroidEventBus]() | yes | It is convenient to use annotation but it’s not as efficient as EventBus. The subscription supports tag (like the Action in Broadcast Receiver) which can make event delivery more accurate and applicable to more usage scenarios. |
156156

157+
## Proguard
158+
159+
```
160+
-keep class org.simple.** { *; }
161+
-keep interface org.simple.** { *; }
162+
-keepclassmembers class * {
163+
@org.simple.eventbus.Subscriber <methods>;
164+
}
165+
```
166+
167+
## AndroidEventBus is adopted in the following app
168+
* [Accupass - Events around you](https://play.google.com/store/apps/details?id=com.accuvally.android.accupass)
157169

158-
159-
160170
## Thanks Note
161171
I really appreciate E-pal “淡蓝色的星期三” for his proposing of bugs and feedback and I hope more and more friends will join our team of AndroidEventBus Development.
162172

163-
173+
164174
## Release Note### V1.0.3 ( 2015.5.23 )1. support Sticky Events.### V1.0.2 ( 2015.2.28 )Solved the problem of failing to receive an event when the parameter of the subscription method is a basic type (int, Boolean, etc.)### V1.0.1 ( 2015.2.13 )1. Solved the problem that the subscription method can’t receive an event because the subscription method is delivered as sub-type when posting an event while it was originally of basic type.
165-
### v1.0 ( 2015.2.9 )1. Release an EventBus library; use @Subscriber annotation to mark subscription method2. The subscription method supports “tag” mark, which makes event delivery more precise.
166-
175+
### v1.0 ( 2015.2.9 )1. Release an EventBus library; use @Subscriber annotation to mark subscription method2. The subscription method supports “tag” mark, which makes event delivery more precise.
167176

168177
## License
169178
```
@@ -181,4 +190,3 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
181190
See the License for the specific language governing permissions and
182191
limitations under the License.
183192
```
184-
Subscriber

0 commit comments

Comments
 (0)