Advertisement
Guest User

Untitled

a guest
Jun 22nd, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.11 KB | None | 0 0
  1. @OnClick(R.id.email_sign_in_button)
  2. public void btnLogIn() {
  3.  
  4. userN = username.getText().toString();
  5. pass = password.getText().toString();
  6. if (userN.isEmpty()) {
  7. username.setError("Username is required");
  8. } else if (pass.isEmpty()) {
  9. password.setError("Password is required");
  10. } else if (pass.length() < 6) {
  11. password.setError("Password must contains at least 6 characters");
  12. }
  13. else
  14. {
  15. modelResponse.emailAddress = userN;
  16. modelResponse.password = pass;
  17. Call<LoginResponse> call = api.login(modelResponse);
  18. call.enqueue(new Callback<LoginResponse>() {
  19. @Override
  20. public void onResponse(Call<LoginResponse> call, Response<LoginResponse> response) {
  21. if (response.isSuccessful()) {
  22. // LoginResponse hasUser = response.body();
  23. // if(hasUser.equals(true)) {
  24. // Toast.makeText(LoginActivity.this, "Success", Toast.LENGTH_SHORT).show();
  25. // PreferencesManager.setUserId(userN, LoginActivity.this);
  26. // Intent intent = new Intent(LoginActivity.this, MainActivity.class);
  27. // startActivity(intent);
  28. // }
  29. // else
  30. // {
  31. // Toast.makeText(LoginActivity.this, "Error", Toast.LENGTH_SHORT).show();
  32. //
  33. // }
  34. Toast.makeText(LoginActivity.this, "Success", Toast.LENGTH_SHORT).show();
  35. }
  36. }
  37. @Override
  38. public void onFailure(Call<LoginResponse> call, Throwable t) {
  39. Toast.makeText(LoginActivity.this, t.getMessage(), Toast.LENGTH_SHORT).show();
  40. }
  41. });
  42. }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement