Duplicate @Subscribe for onStatusCreated event handlers in HomeTimelineFragment?
Not a bug per se, but I'm opening this issue because I'm very confused and I'm not sure if or why the code is correct.
HomeTimelineFragment, which inherits from StatusListFragment, has a method that subscribes to the StatusCreatedEvent.
class HomeTimelineFragment extends StatusListFragment {
@Subscribe // ← should this be here? onStatusCreated is called by StatusListFragment anyway
public void onStatusCreated(StatusCreatedEvent ev){
prependItems(Collections.singletonList(ev.status), true);
}
}
But so does the StatusListFragment itself. It subscribes to said event and then calls the object's (in this case, an instance of HomeTimelineFragment) onStatusCreated method.
abstract class StatusListFragment {
protected void onStatusCreated(StatusCreatedEvent ev){}
@Subscribe
public void onStatusCreated(StatusCreatedEvent ev){
StatusListFragment.this.onStatusCreated(ev); // ← this calls HomeTimelineFragment's onStatusCreated
}
}
This seems to not cause any problems: StatusListFragment's StatusCreatedEvent handler calls HomeTimelineFragment's onStatusCreated method. The called prependItems method was only invoked once, as the breakpoint inside only fired once. (click to reveal screenshot)

However, in my fork, the method is called twice – once for each subscription; actually, as I would expect seeing the two @Subscribe annotations (click to reveal screenshots)
First, it's called from the StatusListFragment's subscription:

Then, directly through HomeTimelineFragment's subscription:

Removing the @Subscribe annotation in HomeTimelineFragment's event handler fixes the issue in my fork (due to the event firing twice, newly published posts were prepended twice as well), but I don't understand why the issue doesn't occur upstream. Is the second subscription there on purpose?
It needed to be there because Otto (the event bus) does not traverse the class hierarchy. But this looks like I forgot to remove it because I moved these event listeners to EventListener inner class for this exact reason 🤔