Skip to content

Commit 4fc2bc8

Browse files
committed
在post event时对event对象判空
1 parent 8bdb35e commit 4fc2bc8

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

lib/androideventbus-1.0.5.jar

20.8 KB
Binary file not shown.

src/org/simple/eventbus/EventBus.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,10 @@ public void post(Object event) {
193193
* @param tag 事件的tag, 类似于BroadcastReceiver的action
194194
*/
195195
public void post(Object event, String tag) {
196+
if (event == null) {
197+
Log.e(this.getClass().getSimpleName(), "The event object is null");
198+
return;
199+
}
196200
mLocalEvents.get().offer(new EventType(event.getClass(), tag));
197201
mDispatcher.dispatchEvents(event);
198202
}
@@ -213,11 +217,13 @@ public void postSticky(Object event) {
213217
* @param tag 事件tag
214218
*/
215219
public void postSticky(Object event, String tag) {
220+
if (event == null) {
221+
Log.e(this.getClass().getSimpleName(), "The event object is null");
222+
return;
223+
}
216224
EventType eventType = new EventType(event.getClass(), tag);
217225
eventType.event = event;
218226
mStickyEvents.add(eventType);
219-
// 处理sticky事件
220-
// mDispatcher.handleStickyEvent(eventType, null);
221227
}
222228

223229
public void removeStickyEvent(Class<?> eventClass) {

0 commit comments

Comments
 (0)