简体   繁体   English

EventBus:如何跟踪?

[英]EventBus: How to keep track?

I am using an event bus (greenrobot) for communication between fragments and activities. 我正在使用事件总线 (greenrobot)在片段和活动之间进行通信。 Works great. 效果很好。

But one thing I was wondering about: How do people keep track of where these are fired? 但是我想知道的一件事是:人们如何跟踪这些被解雇的地点?

Example: When I see an onEvent() method somewhere, how can I find the places where this gets fired? 示例:当我在某个地方看到onEvent()方法时,如何找到触发该事件的地方?

Granted you are using IntelliJ Idea/Android Studio, and the method is onEvent*(E ...) : 授予您正在使用IntelliJ Idea / Android Studio的方法是onEvent*(E ...)

  • Ctrl + click on E will move you to E class file Ctrl +单击E将您移至E类文件
  • Ctrl + click again on E class (as in eg public class E ) will show you all the usages of E class in general. 按住Ctrl键并再次单击E类(例如在public class E中 ),通常会向您显示E类的所有用法。 You may want to filter out import statements in the show pop out dialog by clicking on the italized , blue i icon. 您可能想要通过单击斜体蓝色i图标来过滤掉显示弹出对话框中的导入语句。

Bonus: If the event class has only one constructor, it's better to ctrl + click it instead of class name. 奖励:如果事件类只有一个构造函数,则最好Ctrl +单击它而不是类名。 This will show you places where the event object is created. 这将显示创建事件对象的位置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM