Questions tagged [greenrobot-eventbus]

EventBus is an Android optimized publish/subscribe event bus that simplifies communication between Activities, Fragments, Threads, Services, etc. Less code, better quality.

EventBus is an Android optimized publish/subscribe event bus. A typical use case for Android apps is gluing Activities, Fragments, and background threads together. Conventional wiring of those elements often introduces complex and error-prone dependencies and life cycle issues. With EventBus propagating listeners through all participants (e.g. background service -> activity -> multiple fragments or helper classes) becomes deprecated. EventBus decouples event senders and receivers and thus simplifies communication between app components. Less code, better quality. And you don't need to implement a single interface!

General Usage and API:

In EventBus, subscribers implement event handling methods and register themselves to the bus. Posted events are delivered to matching event handling methods based on their event type (the Java class/interfaces implemented by the event).

Using EventBus takes four simple steps:

  1. Implement any number of event handling methods in the subscriber:

    public void onEvent(AnyEventType event) {}

  2. Register subscribers:

    eventBus.register(this);

  3. Post events to the bus:

    eventBus.post(event);

  4. Unregister subscriber:

    eventBus.unregister(this);

More info: https://github.com/greenrobot/EventBus

247 questions
1
vote
2 answers

Asynchronous Firebase Task with RecyclerView in ViewPager

I'm trying to load the same RecylerView data from the Firebase, and later change simple things in the data Problem: in case of 2 pages No data is appearing on the first page, in case of 3 pages the first pages is not appearing and the startup and…
1
vote
0 answers

Can an Activity register for both Sticky and non-Sticky Events in EventBus Android

In my activity, I want to register it for both [Sticky and Noo-Sticky Events]. Because I am posting both type of events from Service which should be fired in My Activity ... Typically, I want to achieve this…
Kesha
  • 497
  • 6
  • 19
1
vote
0 answers

Unable to bind RecyclerView using EventBus in android Tablets

I am using Green Robot's EventBus for internal event messaging, I want to display data in my RecyclerView using EventBus. The problem is EventBus post message is received correctly and displays data on Android 5'' devices, but the same code is not…
1
vote
1 answer

Getting: java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState when trying to show a DialogFragment

So I'm doing this thing after user gets back to my activity from a payment service: @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { Bundle metadata = getMetadata(); if (metadata == null ||…
Marek M.
  • 3,799
  • 9
  • 43
  • 93
1
vote
1 answer

Mosby & EventBus

I am trying to develop an app using Mosby and EventBus. First event I want to have is after user login, creating a sticky event so every screen can access Login info at all times. Based off the Mosby mail sample, I have a BasePresenter like…
M Rajoy
  • 4,028
  • 14
  • 54
  • 111
1
vote
1 answer

Proguard green robot event bus

I'm using Event bus on my app. following the docs I've added # Green Robot Eventbus -keepattributes *Annotation* -keepclassmembers class ** { @org.greenrobot.eventbus.Subscribe ; } -keep enum org.greenrobot.eventbus.ThreadMode { *;…
rkmax
  • 17,633
  • 23
  • 91
  • 176
1
vote
1 answer

How to use Eventbus in a widget?

I'm trying to figure out how I can use the Greenbot Eventbus library in my AppWidgetProvider. I've tried the following, which doesn't work: public class SimpleWidgetProvider extends AppWidgetProvider { RemoteViews remoteViews; @Override …
Helenesh
  • 3,999
  • 2
  • 21
  • 36
1
vote
0 answers

Greenrobot's EventBus performance drawbacks

I have been using Greenrobot's Eventbus for it's simplicity for a while. I wonder if there is a performance loss if I use it in a scenario where I quite often post an event(4 times a second), and there is multiple recipients of the event, instead…
ikbal
  • 1,844
  • 4
  • 26
  • 46
1
vote
0 answers

MVP and EventBus : who is appropriate for listening events - view or presenter?

I am using Model-View-Presenter design pattern with eventbus. I have a presenter that posts an event in eventbus whenever some information is updated like this: public class HomeScreenPresenter extends BaseHomePresenter { ... ... …
Krupal Shah
  • 8,949
  • 11
  • 57
  • 93
1
vote
0 answers

Greenrobot EventBus sticky events priorities?

Since Greenrobot EventBus events order is not guaranteed by default is there any chance to set sticky events priorities to make the right order? I need to restore events order somehow after listener unregistered/registrered for screen rotation…
4ntoine
  • 19,816
  • 21
  • 96
  • 220
1
vote
1 answer

handle screen rotation with 3 fragments, every one with 3 different layouts

I stuck in a little bit problem. I have situation like this: Login activity with one layout. Three Fragment every one with three different layouts, (Phone portrait, landscape, Tablet landscape) For better image, Fragments function is: login,…
1
vote
1 answer

Eventbus (greenrobot) event when subscriber is unregistered

I have a requirement where a service needs to be able to cancel a network request when all subscribers have unregistered from a specific event. I am using Greenrobot EventBus and as far as I can tell there is nothing built in that will send an event…
user3265561
  • 812
  • 7
  • 22
1
vote
0 answers

Updating dialogfragment views from outside the fragment

Is it possible to update any of the views of a dialogfragment, like a textview from the parent activity or fragment? I have a progressdialog that should be dismissed once some text has been loaded from a service and displayed in the textview. The…
1
vote
0 answers

Parsing Tumblr Json using Retrofit, Gson, and EventBus

My goal is to extract all the posts from my Tumblr Json data, specifically the post's id, post's url, post tags, post's caption, and post's original size url (photo). A snippet of my Tumblr Json is included below. { "meta": { "status": 200, …
Ian Fong
  • 11
  • 1
1
vote
4 answers

GreenRobot EventBus error : No subscribers registered for event

I am trying to post event from Activity to Service using GreenRobot EventBus. But when I try to post event the logcat is showing the following message : No subscribers registered for event class com.example.dhaval.homeexamples.CallBackEvent No…
Dhaval
  • 2,724
  • 2
  • 24
  • 33