Esempio n. 1
0
  /**
   * Method to check the validation on the page
   *
   * @return
   */
  private boolean checkValidation() {
    boolean isAllFieldCorrect = true;
    if (strUserName.length() == 0 && strPassword.length() == 0) {
      isAllFieldCorrect = false;
      mEdtUserName.requestFocus();
      Validation.hasText(LoginActivity.this, mEdtUserName, mllUserName);
      Validation.hasText(LoginActivity.this, mEdtPassword, mllPassword);
      ErrorMsgDialog.showErrorAlert(
          LoginActivity.this, "", getString(R.string.wrng_str_empty_requried_field));

    } else if (strUserName.length() == 0) {
      isAllFieldCorrect = false;
      mEdtUserName.requestFocus();
      Validation.hasText(LoginActivity.this, mEdtUserName, mllUserName);
      ErrorMsgDialog.showErrorAlert(
          LoginActivity.this, "", getString(R.string.wrng_str_empty_requried_field));
    } else if (!Validation.isEmailAddress(LoginActivity.this, mEdtUserName, mllUserName, true)) {
      mEdtUserName.requestFocus();
      isAllFieldCorrect = false;
      Validation.isEmailAddress(LoginActivity.this, mEdtUserName, mllUserName, true);
      ErrorMsgDialog.showErrorAlert(
          LoginActivity.this, "", getString(R.string.wrng_str_invalid_email));
    } else if (strPassword.length() == 0) {
      isAllFieldCorrect = false;
      mEdtPassword.requestFocus();
      Validation.hasText(LoginActivity.this, mEdtPassword, mllPassword);
      ErrorMsgDialog.showErrorAlert(
          LoginActivity.this, "", getString(R.string.wrng_str_empty_requried_field));
    } else {
      isAllFieldCorrect = true;
    }
    return isAllFieldCorrect;
  }
Esempio n. 2
0
  /**
   * parseLoginService
   *
   * @param responseStr
   * @throws Exception
   */
  private void parseLoginService(String responseStr) throws Exception {
    Log.i("Login", responseStr);
    Gson gson = new Gson();
    LoginResponseModel get_Response = gson.fromJson(responseStr, LoginResponseModel.class);

    if (get_Response != null) {
      if (get_Response.getReponseCode().equals(ApplicationConstants.SUCCESS_CODE)) {
        try {
          setDataToMemory(get_Response);
        } catch (Exception ex) {
          ex.printStackTrace();
        }
        // startService(new Intent(LoginActivity.this,NotificationService.class));
        // NotificationAlart.stop(LoginActivity.this);
        // NotificationAlart.start(LoginActivity.this);
        saveSharedPreference.setIsLogin(LoginActivity.this, "");
        if (null != saveSharedPreference.getGroupId(LoginActivity.this)
            && !saveSharedPreference.getGroupId(LoginActivity.this).equals("")) {
          moveToDashboardScreen();
        } else {
          moveToGroupSelectionActivity();
        }

      } else {
        ErrorMsgDialog.showErrorAlert(LoginActivity.this, "", get_Response.getMessage());
      }
    } else {
      ErrorMsgDialog.showErrorAlert(
          LoginActivity.this, "", getString(R.string.wrng_str_server_error));
    }
  }
Esempio n. 3
0
  @Override
  public void onClick(View view) {
    if (view == mBtnLogin) {

      strUserName = mEdtUserName.getText().toString().trim();
      strPassword = mEdtPassword.getText().toString().trim();
      if (checkValidation()) {
        // Call the web service
        try {
          if (AppUtils.isOnline(LoginActivity.this)) {
            setupPushNotification();
            mProgressHUD = ProgressHUD.show(LoginActivity.this, "", true, true);
            mProgressHUD.setCancelable(false);
            callWebservice();
          } else {
            ErrorMsgDialog.showErrorAlert(
                LoginActivity.this, "", getString(R.string.wrng_str_lost_internet_error));
          }
        } catch (Exception ex) {
          ex.printStackTrace();
        }
      }
    } else if (view == mTxtvForgotPassword) {
      Intent intObj = new Intent(LoginActivity.this, ForgotPasswordActivity.class);
      startActivity(intObj);
      overridePendingTransition(0, 0);
    }
  }