Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void performRegistration() {
- showProgressDialog(true);
- //Make an api call to sign in
- //new SignInTask().execute(username.getText().toString(), password.getText().toString());
- ApiManager.getApiInterface().registration(new AuthenticationRequest(username.getText().toString().trim(), password.getText().toString().trim()))
- .enqueue(new Callback<MessageResponse>() {
- @Override
- public void onResponse(Call<MessageResponse> call, Response<MessageResponse> response) {
- showProgressDialog(false);
- if (response.isSuccessful()) {
- showAlert("Welcome", response.body().getMessage());
- } else {
- try {
- String errorMessage = response.errorBody().string();
- try {
- ErrorResponse errorResponse = new Gson().fromJson(errorMessage, ErrorResponse.class);
- showAlert("line 142 Registration failed", errorResponse.getError());
- } catch (JsonSyntaxException jsonException) {
- showAlert("line 144 Registration Failed", "Something went wrong");
- }
- } catch (IOException e) {
- e.printStackTrace();
- showAlert("line 149 Registration Failed", "Something went wrong");
- }
- }
- }
- @Override
- public void onFailure(Call<MessageResponse> call, Throwable t) {
- showProgressDialog(false);
- showAlert("line 158 Registration Failed", "Something went wrong");
- }
- });
- }
Add Comment
Please, Sign In to add comment