This repository was archived by the owner on Feb 26, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
This repository was archived by the owner on Feb 26, 2023. It is now read-only.
Otto integration #272
Copy link
Copy link
Closed
Labels
Description
I'm using Otto, the bus library from square. I have a couple of methods annotated with @subscribe, which is part of Otto.
When I add @trace, it appears that the @subscribe annotation isn't carried over, so when I post events those methods listen for, nothing happens. When I remove @trace, they fire off as expected.
@EActivity(R.layout.login)
public class LoginActivity extends Activity {
@ViewById
protected EditText username;
@ViewById
protected EditText password;
@ViewById
protected Button loginButton;
@Click({ R.id.loginButton })
public void sendLogin() {
Credentials credentials = new Credentials(
username.getText().toString(),
password.getText().toString()
);
new LoginTask().run(credentials);
}
@Override
public void onResume() {
super.onResume();
BusProvider.getInstance().register(this);
}
@Override
public void onPause() {
super.onPause();
BusProvider.getInstance().unregister(this);
}
// @Trace - won't work here (doesn't preserve @Subscribe?)
@Subscribe
public void onLoginFailure(LoginFailureEvent event) {
Log.w(LoginActivity.class.getName(),"Login Failure");
}
// @Trace - won't work here (doesn't preserve @Subscribe?)
@Subscribe
public void onLoginSuccess(LoginSuccessEvent event) {
Log.w(LoginActivity.class.getName(),"Login Success");
}
}
@EBean
public class LoginTask {
@Background
public void run(Credentials credentials) {
// perform login here
post(true);
}
@UiThread
public void post(boolean success) {
if (success)
BusProvider.getInstance().post(new LoginSuccessEvent());
else
BusProvider.getInstance().post(new LoginFailureEvent());
}
}