EventBus
EventBus copied to clipboard
threadMode = ThreadMode.MAIN UI is not updating
I am posting the event from Main thread and I have subscribed as a ThreadMode.MAIN. My subscribed method is calling but UI is not updating. I want to update the progress status.
Class : Post Event Sample Code:
for(int i = 0; i < 10; i++) { // Doing some operation EventBus.getDefault().post(new MySample(i)); }
Activity : Subscribed Sample Code:
@Subscribe(threadMode = ThreadMode.MAIN) public void updateUI(MySample event) { //Updating UI }
Here updateUI() is calling, but UI is not updating. Please help me with this. Event Bus Version: 3.1.1
Note: If I will post the event from a background thread, UI is updating.
Thank you,
you need to register to the bus to make the @Subscribe
annotated methods be called
Thank you for the response. I have registered already and updateUI() is calling as well. The problem is inside updateUI() my TextView or toast message is not updating/showing. Maybe I did not get you what you are trying to explain. Really I will appreciate getting the help as soon as possible.
Thanks in advance.
@sripati Without a more complete example I guess we just don't know what you are trying to do. -Uwe
I'm setting up a state and putting the code to update the Ui in the onResume method and updating the Ui based on the state in the onResume method
@ggyg123 Do you have the same issue as @sripati? Could you please share a minimal code example and what the issue is?
Maybe you do the registration after you do the post. @sripati
If you unregister in onPause
, then system dialogs and runtime permission dialogs invoke onPause
and make you unregister.
maybe u should use sticky event(post before subscribe)
Closing as original posters have not replied for a long time.