EventBus icon indicating copy to clipboard operation
EventBus copied to clipboard

threadMode = ThreadMode.MAIN UI is not updating

Open sripati opened this issue 5 years ago • 7 comments

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,

sripati avatar Jun 06 '19 14:06 sripati

you need to register to the bus to make the @Subscribe annotated methods be called

Zhuinden avatar Jun 16 '19 17:06 Zhuinden

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 avatar Jun 16 '19 17:06 sripati

@sripati Without a more complete example I guess we just don't know what you are trying to do. -Uwe

greenrobot-team avatar Jun 18 '19 13:06 greenrobot-team

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 avatar Jun 30 '19 02:06 ggyg123

@ggyg123 Do you have the same issue as @sripati? Could you please share a minimal code example and what the issue is?

greenrobot-team avatar Jul 16 '19 08:07 greenrobot-team

Maybe you do the registration after you do the post. @sripati

detsimov avatar Jul 21 '19 04:07 detsimov

If you unregister in onPause, then system dialogs and runtime permission dialogs invoke onPause and make you unregister.

Zhuinden avatar Jul 21 '19 19:07 Zhuinden

maybe u should use sticky event(post before subscribe)

tomridder avatar Mar 16 '23 07:03 tomridder

Closing as original posters have not replied for a long time.

greenrobot-team avatar Mar 27 '23 12:03 greenrobot-team