Created
April 16, 2014 10:32
-
-
Save PuercoPop/10849607 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
loginButton.setOnClickListener(new View.OnClickListener() { | |
public void onClick(View v) { | |
// First check if email or password are empty, if any of those | |
// is empty, focus them. Else try to authenticate on the | |
// endpoint. | |
final EditText email = (EditText) rootView.findViewById(R.id.login_email); | |
final EditText password = (EditText) rootView.findViewById(R.id.login_password); | |
AuthenticatorMock authenticator = new AuthenticatorMock(); | |
try { | |
final User user = authenticator.login(email.getText().toString(), | |
password.getText().toString()); | |
} catch (InvalidCredentialsException e) { | |
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); | |
builder.setTitle(R.string.credential_failure_title) | |
.setMessage(R.string.crentials_failure_message); | |
AlertDialog dialog = builder.create(); | |
} | |
} | |
}); | |
/// ===== | |
public class AuthenticatorMock implements AuthenticatorInterface { | |
public User login(String username, String password) throws InvalidCredentialsException { | |
if (username.equals("Carmen") && password.equals("Sawada")) { | |
return new User("[email protected]"); | |
} else { | |
// TODO: User values/strings.xml | |
throw new InvalidCredentialsException("Credenciales Equivocados"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Execution failed for task ':app:compileDebugJava'.