-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathUniversalEventBusApplication.java
More file actions
81 lines (66 loc) · 2.13 KB
/
UniversalEventBusApplication.java
File metadata and controls
81 lines (66 loc) · 2.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
package it.sysdata.eventdispatcher;
import android.app.Application;
import com.baseandroid.eventbus.GreenRobotEventProcessor;
import com.baseandroid.events.EventDispatcher;
import com.baseandroid.events.EventProcessor;
import com.baseandroid.events.otto.OttoEventProcessor;
import com.baseandroid.events.rx.RxEventProcessor;
/**
* Created by Conversano Luca on 20/11/17.
*/
public class UniversalEventBusApplication extends Application {
private final static String LOG_TAG = UniversalEventBusApplication.class.getSimpleName();
/**
* Defines the type of the event bus.<br>
*/
public enum EventBusType {
/**
* Otto Event Bus
*/
OTTO,
/**
* Rx Event Bus
*/
RX,
/**
* GreenRobot Event Bus
*/
GREENROBOT
}
@Override
public void onCreate() {
super.onCreate();
// init event bus
initEventBus();
}
private void initEventBus() {
//EventBusType eventBusType = EventBusType.OTTO;
//EventBusType eventBusType = EventBusType.RX;
EventBusType eventBusType = EventBusType.GREENROBOT;
switch (eventBusType) {
case OTTO:
initOttoEventBus();
break;
case RX:
initRxEventBus();
break;
case GREENROBOT:
initGreenRobotEventBus();
break;
}
}
private void initRxEventBus() {
RxEventProcessor eventProcessor = (RxEventProcessor) RxEventProcessor.newInstance();
eventProcessor.setVerbose(true);
EventDispatcher.useEventProcessor(eventProcessor);
}
private void initOttoEventBus() {
EventProcessor eventProcessor = (EventProcessor) OttoEventProcessor.newInstance();
EventDispatcher.useEventProcessor(eventProcessor);
}
private void initGreenRobotEventBus() {
GreenRobotEventProcessor eventProcessor = (GreenRobotEventProcessor) GreenRobotEventProcessor.newInstance();
eventProcessor.setVerbose(true);
EventDispatcher.useEventProcessor(eventProcessor);
}
}