Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @OnClick(R.id.email_sign_in_button)
- public void btnLogIn() {
- userN = username.getText().toString();
- pass = password.getText().toString();
- if (userN.isEmpty()) {
- username.setError("Username is required");
- } else if (pass.isEmpty()) {
- password.setError("Password is required");
- } else if (pass.length() < 6) {
- password.setError("Password must contains at least 6 characters");
- }
- else
- {
- modelResponse.emailAddress = userN;
- modelResponse.password = pass;
- Call<LoginResponse> call = api.login(modelResponse);
- call.enqueue(new Callback<LoginResponse>() {
- @Override
- public void onResponse(Call<LoginResponse> call, Response<LoginResponse> response) {
- if (response.isSuccessful()) {
- // LoginResponse hasUser = response.body();
- // if(hasUser.equals(true)) {
- // Toast.makeText(LoginActivity.this, "Success", Toast.LENGTH_SHORT).show();
- // PreferencesManager.setUserId(userN, LoginActivity.this);
- // Intent intent = new Intent(LoginActivity.this, MainActivity.class);
- // startActivity(intent);
- // }
- // else
- // {
- // Toast.makeText(LoginActivity.this, "Error", Toast.LENGTH_SHORT).show();
- //
- // }
- Toast.makeText(LoginActivity.this, "Success", Toast.LENGTH_SHORT).show();
- }
- }
- @Override
- public void onFailure(Call<LoginResponse> call, Throwable t) {
- Toast.makeText(LoginActivity.this, t.getMessage(), Toast.LENGTH_SHORT).show();
- }
- });
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement