Sign in Go Pro

Event Bus

Handling Events with EventBus

This lesson is for PRO members.

Upgrade today to get access to all the PRO lessons.

Unlock this lesson
Autoplay

Up next

Previous

About

EventBus is an open-source library that uses the publisher/subscriber pattern to simplify communication between the various components in your application. Learn how to incorporate it into your application.

In this lesson you will learn:

How to configure EventBus
How to register with the EventBus
How to subscribe to and post events

Comments

Thanks for a simple tutorial.

You're welcome!

Where is the source code?

Rodrigo, we just updated the lessons. Please see the "Sample Code" link in the lesson.

Thanks again Donn!

Thanks Donn!
Always helping me. Thanks man!

Donn, unfortunately, the link posted is the wrong one!

See:
https://caster.io/lessons/handling-events-eventbus-part-1#commentid-702

In the source code, there isn't a Presenter.
What is showed in the videos differs from the content of the source code!
Rodrigo Cericatto- 1 day ago
Reply Edit

In the source code, there are no BookService.java, and no
BooksLoadedSuccessfulEvent.java.
Rodrigo Cericatto- 1 day ago
Reply Edit

Hey Donn, the source code is WRONG. The correct one is this:
https://github.com/adavis/adept-android/tree/eventbus

You need to update this.

In the source code, there isn't a Presenter.
What is showed in the videos differs from the content of the source code!

In the source code, there are no BookService.java, and no BooksLoadedSuccessfulEvent.java.

It has been WEEKS that I am trying to compile the source code below, and I got no success.
https://github.com/adavis/adept-android/tree/eventbus

Donn, Annyce, you don't you help me here?

Weeks!! I am frustrated.

It seems that you are struggling to compile code that is many years old. I would recommend that you review this commit as it's a great example of how you would need to update dependencies and source code from older versions of the Android Gradle Plugin and Android SDK:
https://github.com/adavis/adept-android/commit/16fc47f9831a363da78fc9948fafea67e45c3e3e

Further, it appears that you are unable to follow the structure of the existing codebase to locate key files. If you are using Android Studio, I would recommend doing a class name search using either the dropdown menu: "Navigate" -> "Class" and typing the name of the class that you are looking for. Or alternatively, you can use a shortcut command, such as "Cmd+O" if you are on a Mac.

All of the classes referenced in the video are indeed available on the "eventbus" branch. In fact, here is the BookService.java class that you mentioned in your comment was not present => https://github.com/adavis/adept-android/blob/eventbus/app/src/main/java/info/adavis/adeptandroid/data/BookService.java.

I hope that this can assist you in your efforts to use the EventBus library.

Further, I would recommend that you create your own project from Android Studio that uses the latest versions of the Android Gradle Plugin and Android SDK. Then proceed to incorporate the new things that you learn in the video. Expecting source code that is 3 or 4 years old to compile is an unreasonable expectation considering the speed with which Android development changes.

Hello Annyce.

This link helped me building the app:
https://github.com/adavis/adept-android/commit/16fc47f9831a363da78fc9948fafea67e45c3e3e

Thanks for that!

Now, the problem is that the app runs at localhost and I don't know how to create a server in my machine to run this server:
public static final String BASE_URL = "http://10.0.0.40:8080";

Unfortunately, I don't have much knowledge about Web Servers and etc. I will search about it in Web, but a help from you here would be much appreciated.

One more thing: I know that the code from this course is from years ago, and also that it may seem annoying for you or Donn to help students like me, that are facing difficulties. But that's the main reason because I got enrolled into Caster.IO: to LEARN.

And sometimes, when Stack Overflow can't help me, I think t ask for your guidance, from you and Donn.

>
You need to go PRO to post comments.

Lessons in Event Bus