Guest User

Untitled

a guest
Mar 16th, 2018
30
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.95 KB | None | 0 0
  1. private void performRegistration() {
  2.         showProgressDialog(true);
  3.         //Make an api call to sign in
  4.         //new SignInTask().execute(username.getText().toString(), password.getText().toString());
  5.         ApiManager.getApiInterface().registration(new AuthenticationRequest(username.getText().toString().trim(), password.getText().toString().trim()))
  6.                 .enqueue(new Callback<MessageResponse>() {
  7.                     @Override
  8.                     public void onResponse(Call<MessageResponse> call, Response<MessageResponse> response) {
  9.                         showProgressDialog(false);
  10.                         if (response.isSuccessful()) {
  11.                             showAlert("Welcome", response.body().getMessage());
  12.                         } else {
  13.                             try {
  14.                                 String errorMessage = response.errorBody().string();
  15.                                 try {
  16.                                     ErrorResponse errorResponse = new Gson().fromJson(errorMessage, ErrorResponse.class);
  17.                                     showAlert("line 142 Registration failed", errorResponse.getError());
  18.                                 } catch (JsonSyntaxException jsonException) {
  19.                                     showAlert("line 144 Registration Failed", "Something went wrong");
  20.                                 }
  21.                             } catch (IOException e) {
  22.                                 e.printStackTrace();
  23.                                 showAlert("line 149 Registration Failed", "Something went wrong");
  24.                             }
  25.                         }
  26.                     }
  27.                     @Override
  28.                     public void onFailure(Call<MessageResponse> call, Throwable t) {
  29.                         showProgressDialog(false);
  30.                         showAlert("line 158 Registration Failed", "Something went wrong");
  31.                     }
  32.                 });
  33.     }
Add Comment
Please, Sign In to add comment