Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
This repository was archived by the owner on Feb 26, 2023. It is now read-only.
This repository was archived by the owner on Feb 26, 2023. It is now read-only.

Otto integration #272

Copy link
Copy link
@mandrachek

Description

@mandrachek
Issue body actions

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());        
    }
}
Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.