コード例 #1
0
  private void UpdateClone() {
    if (mUserInfo.roles != null && mUserInfo.roles.size() > 0) {
      mUserInfo.password = mPasswordData;
      if (mLayout.getUserLoginID().equals("")) {
        mUserInfo.login_id = null;
      } else {
        mUserInfo.login_id = mLayout.getUserLoginID();
      }
    } else {
      mUserInfo.login_id = null;
      mUserInfo.password = null;
    }

    mUserInfo.name = mLayout.getUserName();
    mUserInfo.email = mLayout.getEmail();
    mUserInfo.phone_number = mLayout.getTelephone();

    if (mPinSwitch.getOn()) {
      if (mPinData != null && mPinData.length() > 3) {
        mUserInfo.pin_exist = true;
        mUserInfo.pin = mPinData;
      }
    } else {
      mUserInfo.pin = "";
    }

    switch (mPhotoStatus) {
      case NOT_MODIFY:
        if (mUserInfo.photo != null) {
          mBackupPhoto = mUserInfo.photo;
        }
        mUserInfo.photo = null;
        break;
      case MODIFY:
        break;
      case DELETE:
        mUserInfo.photo = "";
        break;
    }
  }
コード例 #2
0
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    if (super.onOptionsItemSelected(item)) {
      return true;
    }
    switch (item.getItemId()) {
      case R.id.action_save:
        if (mInvalidChecker.isEmptyString(
            getString(R.string.info), getString(R.string.user_create_empty), mLayout.getUserID())) {
          return true;
        }

        if (mLayout.isOperator()) {
          if (mInvalidChecker.isEmptyString(
              getString(R.string.info),
              getString(R.string.user_create_empty_idpassword),
              mLayout.getUserLoginID())) {
            return true;
          }
          if (!mUserInfo.password_exist) {
            if (mPasswordData == null) {
              mPopup.show(
                  PopupType.ALERT,
                  getString(R.string.info),
                  getString(R.string.user_create_empty_idpassword),
                  null,
                  null,
                  null);
              return true;
            }
          }
        }

        if (mInvalidChecker.isInvalidEmail(
            getString(R.string.info), getString(R.string.invalid_email), mLayout.getEmail())) {
          return true;
        }

        if (mPinData != null && mPinData.length() > 0 && mPinData.length() < 4) {
          mPopup.show(
              PopupType.ALERT,
              getString(R.string.info),
              getString(R.string.pincount),
              null,
              null,
              null);
          return true;
        }

        UpdateClone();
        mPopup.showWait(true);
        User user = null;
        try {
          user = mUserInfo.clone();
        } catch (CloneNotSupportedException e) {
          e.printStackTrace();
          return true;
        }
        user.setMyProfile();
        mUserDataProvider.modifyMyProfile(
            TAG, user, mModifyUserListener, mModifyUserErrorListener, null);
        return true;
      default:
        break;
    }
    return false;
  }