Example #1
0
  public static boolean verify(final Context context, final String username, String password) {

    boolean verifyResult = false;
    final ATIPUser user = new ATIPUser();
    user.setUserName(username);
    user.setPwd(password);

    ATIPRestInterface service = ATIPRestService.getInstance(context);

    Call<Boolean> call = service.verify(user);
    call.enqueue(
        new Callback<Boolean>() {
          @Override
          public void onResponse(Call<Boolean> call, Response<Boolean> response) {
            if (response.body()) {
              login(context, username);
            }
          }

          @Override
          public void onFailure(Call<Boolean> call, Throwable t) {
            Log.v("LoginUtils", t.getMessage());
          }
        });

    return verifyResult;
  }
Example #2
0
  public static void login(Context context, String username) {

    ATIPRestInterface service = ATIPRestService.getInstance(context);

    Call<ATIPUser> call = service.getUserByUsername(username);
    call.enqueue(
        new Callback<ATIPUser>() {
          @Override
          public void onResponse(Call<ATIPUser> call, Response<ATIPUser> response) {
            ATIPUser user = response.body();
            SessionUser.getInstance().setUser(user);
          }

          @Override
          public void onFailure(Call<ATIPUser> call, Throwable t) {
            Log.v("LoginUtils", t.getMessage());
          }
        });
  }