Guest User

Untitled

a guest
Nov 4th, 2017
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. public void onRegisterClick(View v) {
  2. progressBar.setVisibility(View.VISIBLE);
  3. progressBar.animate().alpha(1).setDuration(500).start();
  4. final String username = usernameEditText.getText().toString();
  5. final String password = passwordEditText.getText().toString();
  6. RegistrationDTO dto = new RegistrationDTO(username, password);
  7. registrationService.callback(new Callback() {
  8. @Override
  9. public void onResponse(Call<RegistrationDTO> call, Response<RegistrationResult> response) {
  10. progressBar.setVisibility(View.GONE);
  11. storage.putString(USERNAME, username);
  12. storage.putString(PASSWORD, password);
  13.  
  14. Intent nextActivity = new Intent(RegistrationActivity.this, NextActivity.class);
  15. nextActivity.launch();
  16. }
  17.  
  18. @Override
  19. public void onFailure(Throwable t) {
  20. progressBar.setVisibility(View.GONE);
  21. if (t instanceof ConnectException) {
  22. new CustomAlertDialog.Builder()
  23. .setMessage("Internet unavailable")
  24. .build()
  25. .show();
  26. }
  27. else {
  28. new CustomAlertDialog.Builder()
  29. .setMessage("An unknown error has occurred")
  30. .build()
  31. .show();
  32. }
  33. }
  34. }).enqueue();
  35. }
Add Comment
Please, Sign In to add comment