forked from androidannotations/androidannotations
-
Notifications
You must be signed in to change notification settings - Fork 0
OttoIntegration
PerfectCarl edited this page Dec 29, 2013
·
18 revisions
Since AndroidAnnotations 3.0
AndroidAnnotations integrates with Otto 2.0-wip. This version has yet to be released and work happens in a specific [2.0-wip branch] (https://github.com/square/otto/tree/2.0-wip). [This ticket] (https://github.com/square/otto/issues/61) tracks Otto's progress on that matter.
You can download a [build here] (http://eeee) or build it yourself:
git clone https://github.com/square/otto -b2.0-wip
cd otto
mvn clean install -DskipTests
- Add AndroidAnnotations to your project.
- Add
Otto 2.0-wipto your project. - Use
@Suscribeand@Postannotations to declare the event you want to broker between your components. - Looking for a working example (with Dagger integration)? Have a look CleanAndroidCode!
The following code (taken from the CleanAndroidCode) shows you how an Activity notifies its Fragment that the title has been updated.
public class UpdateTitleEvent {
public final CharSequence title;
public UpdateTitleEvent(String title) {
this.title = title;
}
}
@EActivity(R.layout.hello_activity)
public class HelloAndroidActivity extends BaseActivity {
@Subscribe
public void onUpdateTitle(UpdateTitleEvent event) {
setTitle(event.title);
}
}@EFragment(R.layout.hello_fragment)
public class HelloFragment extends BaseFragment {
@Inject
Bus bus;
@Click
void fragmentButtonClicked() {
bus.post(new UpdateTitleEvent("Button clicked"));
}
}AndroidAnnotations was created by Pierre-Yves Ricau and is sponsored by eBusinessInformations.
09/11/2014 The 3.2 release is out !
- Get started!
- Download
- Cookbook, full of recipes
- Customize annotation processing
- List of all available annotations
- Release Notes
- Examples
- Read the FAQ
- Join the Mailing list
- Create an issue
- Tag on Stack Overflow