Advertisement
Guest User

Untitled

a guest
Apr 20th, 2016
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.83 KB | None | 0 0
  1. public void logIn(View v){
  2. boolean validationError = false;
  3. String username = username_text.getText().toString();
  4. String password = password_text.getText().toString();
  5.  
  6. if(isEmpty(username_text)){
  7. validationError=true;
  8. Toast toast = Toast.makeText(getApplicationContext(),"Enter your username",Toast.LENGTH_SHORT);
  9. toast.show();
  10. }
  11. if(isEmpty(password_text)){
  12. validationError=true;
  13. Toast toast = Toast.makeText(getApplicationContext(),"Enter your password",Toast.LENGTH_SHORT);
  14. toast.show();
  15. }
  16.  
  17. if(!validationError){
  18. /**
  19. * Log In User:
  20. */
  21. Backendless.UserService.login(username, password, new AsyncCallback<BackendlessUser>() {
  22. @Override
  23. public void handleResponse(BackendlessUser response) {
  24.  
  25. Intent intent = new Intent(MainActivity.this, LoadingActivity.class);
  26. startActivity(intent);
  27. }
  28.  
  29. @Override
  30. public void handleFault(BackendlessFault fault) {
  31. if(fault.getCode().equals("3003")){
  32. Toast toast = Toast.makeText(getApplicationContext(),"Password does not match username",Toast.LENGTH_SHORT);
  33. toast.show();
  34. }else if(fault.getCode().equals("3087")){
  35. Toast toast = Toast.makeText(getApplicationContext(),"This account still awaits confirmation. Check your email inbox",Toast.LENGTH_SHORT);
  36. toast.show();
  37. }
  38. else{
  39. System.out.println("ERROR ON LOGIN" + fault.getCode() + " " + fault.getMessage());
  40. }
  41. }
  42. },true);
  43.  
  44. }
  45.  
  46.  
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement