Esempio n. 1
0
  /**
   * Finish login
   *
   * @param response response
   */
  private void finishLogin(Response<UserEntity> response) {

    if (response == null || response.body() == null) {

      CustomPreferences.setPreferences(Constants.PREF_USERNAME, "");
      CustomPreferences.setPreferences(Constants.PREF_PASSWORD, "");
      CustomPreferences.setPreferences(Constants.PREF_USER_ID, 0l);
      CustomPreferences.setPreferences(Constants.PREF_ACC_ID, 0l);
      Utilities.showAlertDialog(
          LoginActivity.this,
          getString(R.string.login_fail),
          getString(R.string.try_again),
          getString(R.string.ok),
          "",
          null,
          null,
          false);
      edtPassword.setText("");
      edtPassword.requestFocus();
      return;
    }

    CustomPreferences.setPreferences(Constants.PREF_USER_ID, response.body().getId());
    CustomPreferences.setPreferences(Constants.PREF_ACC_ID, response.body().getAccountId());
    startActivity(new Intent(this, MainActivity.class));
    finish();
  }
Esempio n. 2
0
 @Override
 public void onClick(View view) {
   super.onClick(view);
   switch (view.getId()) {
     case R.id.login_btn_login:
       Utilities.hideSoftKeyBoard(LoginActivity.this);
       doLogin();
       break;
   }
 }