If you use EventBus from greenrobot, you will find EventBusGraph very helpful.
EventBusGraph Scans java files, looking for post() and onEvent() methods and generates an HTML file that shows the relationships between events, posts and onEvents.
To view the graphs, it is necessary to add the viz.js library in the same folder where the HTML file is. You can download it from:
-
Create a config_file with the base paths of the files to scan and the output folder:
path/to/base/one
path/to/another_base/two
... more paths ...
path/to/the_last_base
path_out = path/to/output_folder -
Run the command:
python eventbus_graph.py config_file -
Open the generated HTML file in your favorite browser.
- Use:
EventBus.getDefault()ormEventBus, example:
EventBus.getDefault().post(new String("Hello"));
EventBus mEventBus = EventBus.getDefault();
mEventBus.post(new String("Hello"));- Use cast to the same class if you create your objects outside the post, example:
String event = "message";
EventBus.getDefault().post((String)event);- Doesn't recognize comments (at least for now). You shouldn't comment post or onEvents methods. They will be showed any way.
- Unable to analyze if the methods are called between the register() and unregister() methods.
