Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

View's onClick Listener #3

Open
mantas84 opened this issue Nov 9, 2016 · 1 comment
Open

View's onClick Listener #3

mantas84 opened this issue Nov 9, 2016 · 1 comment

Comments

@mantas84
Copy link

mantas84 commented Nov 9, 2016

[Question]

callOnClick();

https://github.com/ecgreb/mvpc/blob/master/app/src/main/java/com/example/ecgreb/mvpc/view/LoginForm.java#L122

mLoginFormView.setOnClickListener(new OnClickListener() {
      @Override public void onClick(View v) {
        attemptLogin();
      }
});

https://github.com/ecgreb/mvpc/blob/master/app/src/main/java/com/example/ecgreb/mvpc/controller/LoginActivity.java#L29-#L33

Could you explain more about this? Is it scalable?

@ecgreb
Copy link
Owner

ecgreb commented Nov 10, 2016

Since the view only has one event the activity/controller cares about (login button click) I decided to hijack the OnClickListener interface to simplify the implementation.

If there was more than one event, for example a login button click and a cancel button click, you could instead use a custom interface.

interface LoginFormListener {
  public void onLoginButtonClick();
  public void onCancelButtonClick();
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants