You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
These are posted from 2 different Classes in following order:
// Send Notification to refresh the RecyclerView:Timber.d("Send ReadingsDataDidChangeNotification");
EventBus.getDefault().postSticky(newReadingsDataDidChangeNotification());
// Send Notification to highlight the updated row in the RecyclerView for this meter reading:Timber.d("Send MeterReadingSavedNotification");
EventBus.getDefault().postSticky(newMeterReadingSavedNotification(meter.token));
For the the receiving class MeterReadingsFragment it's important to always execute the action for ReadingsDataDidChangeNotification first, therefor it's set to a higher priority (2) than MeterReadingSavedNotification (1):
@OverridepublicvoidonStart() {
super.onStart();
Timber.d("Register EventBus");
EventBus.getDefault().register(this);
}
@OverridepublicvoidonStop() {
super.onStop();
Timber.d("Unregister EventBus");
EventBus.getDefault().unregister(this);
}
@Subscribe(priority = 2, sticky = true, threadMode = ThreadMode.MAIN) // Highest priority to always be executed firstpublicvoidonMessageEvent(ReadingsDataDidChangeNotificationevent) {
Timber.d("ReadingsDataDidChangeNotification");
// Reload RecyclerView:
}
@Subscribe(priority = 1, sticky = true, threadMode = ThreadMode.MAIN)
publicvoidonMessageEvent(MeterReadingSavedNotificationevent) {
Timber.d("MeterReadingSavedNotification");
// Highlight row in RecyclerView and after a delay unhighlight:
}
However, when checking Logcat, the order is always the wrong one; MeterReadingSavedNotification is always called first, no matter what we do:
We're struggling for days now to receive the events in the correct order.
However, no matter what we do, events are always handled in the wrong order.
We use 2 different event classes:
These are posted from 2 different Classes in following order:
For the the receiving class
MeterReadingsFragment
it's important to always execute the action forReadingsDataDidChangeNotification
first, therefor it's set to a higherpriority
(2) thanMeterReadingSavedNotification
(1):However, when checking Logcat, the order is always the wrong one; MeterReadingSavedNotification is always called first, no matter what we do:
We have:
ThreadMode
options.@Subscribe()
events inMeterReadingsFragment
.It seems that
priority
has no effect at all.Is this a bug, or do we implement it wrong?
The text was updated successfully, but these errors were encountered: