@Override
  public void onClick(View v) {
    String username = usernameField.getText().toString();
    String password = passwordField.getText().toString();
    String passwordAgain = confirmPasswordField.getText().toString();

    String email = null;
    if (config.isParseLoginEmailAsUsername()) {
      email = usernameField.getText().toString();
    } else if (emailField != null) {
      email = emailField.getText().toString();
    }

    String name = null;
    if (nameField != null) {
      name = nameField.getText().toString();
    }

    if (username.length() == 0) {
      if (config.isParseLoginEmailAsUsername()) {
        showToast(R.string.com_parse_ui_no_email_toast);
      } else {
        showToast(R.string.com_parse_ui_no_username_toast);
      }
    } else if (password.length() == 0) {
      showToast(R.string.com_parse_ui_no_password_toast);
    } else if (password.length() < minPasswordLength) {
      showToast(
          getResources()
              .getQuantityString(
                  R.plurals.com_parse_ui_password_too_short_toast,
                  minPasswordLength,
                  minPasswordLength));
    } else if (passwordAgain.length() == 0) {
      showToast(R.string.com_parse_ui_reenter_password_toast);
    } else if (!password.equals(passwordAgain)) {
      showToast(R.string.com_parse_ui_mismatch_confirm_password_toast);
      confirmPasswordField.selectAll();
      confirmPasswordField.requestFocus();
    } else if (email != null && email.length() == 0) {
      showToast(R.string.com_parse_ui_no_email_toast);
    } else if (name != null && name.length() == 0 && config.isParseSignupNameFieldEnabled()) {
      showToast(R.string.com_parse_ui_no_name_toast);
    } else {
      ParseUser user = ParseObject.create(ParseUser.class);

      // Set standard fields
      user.setUsername(username);
      user.setPassword(password);
      user.setEmail(email);

      // Set additional custom fields only if the user filled it out
      if (name.length() != 0 && config.isParseSignupNameFieldEnabled()) {
        user.put(USER_OBJECT_NAME_FIELD, name);
      }

      loadingStart();
      user.signUpInBackground(
          new SignUpCallback() {

            @Override
            public void done(ParseException e) {
              if (isActivityDestroyed()) {
                return;
              }

              if (e == null) {
                loadingFinish();
                signupSuccess();
              } else {
                loadingFinish();
                if (e != null) {
                  debugLog(
                      getString(R.string.com_parse_ui_login_warning_parse_signup_failed)
                          + e.toString());
                  switch (e.getCode()) {
                    case ParseException.INVALID_EMAIL_ADDRESS:
                      showToast(R.string.com_parse_ui_invalid_email_toast);
                      break;
                    case ParseException.USERNAME_TAKEN:
                      showToast(R.string.com_parse_ui_username_taken_toast);
                      break;
                    case ParseException.EMAIL_TAKEN:
                      showToast(R.string.com_parse_ui_email_taken_toast);
                      break;
                    default:
                      showToast(R.string.com_parse_ui_signup_failed_unknown_toast);
                  }
                }
              }
            }
          });
    }
  }
  // View.OnClickListener method (create account button clicked)
  @Override
  public void onClick(View view) {
    String password = mEdtPassword.getText().toString();
    String passwordAgain = mEdtConfirmPassword.getText().toString();
    String name = mEdtName.getText().toString();

    if (password.length() == 0) {
      showSnack(R.string.com_parse_ui_no_password_toast);
    } else if (password.length() < mMinPasswordLength) {
      showSnack(
          getResources()
              .getQuantityString(
                  R.plurals.com_parse_ui_password_too_short_toast,
                  mMinPasswordLength,
                  mMinPasswordLength));
    } else if (passwordAgain.length() == 0) {
      showSnack(R.string.com_parse_ui_reenter_password_toast);
    } else if (!password.equals(passwordAgain)) {
      showSnack(R.string.com_parse_ui_mismatch_confirm_password_toast);
      mEdtConfirmPassword.selectAll();
      mEdtConfirmPassword.requestFocus();
    } else if (name.length() == 0) {
      showSnack(R.string.com_parse_ui_no_name_toast);
    } else {
      final ParseUser user = ParseObject.create(ParseUser.class);

      // Set standard fields
      user.setUsername(mEmailAddress);
      user.setEmail(mEmailAddress);
      user.setPassword(password);

      // Set additional custom fields only if the user filled it out
      if (name.length() != 0) {
        user.put(SignInActivity.USER_OBJECT_NAME_FIELD, name);
      }

      loadingStart();
      user.signUpInBackground(
          new SignUpCallback() {

            @Override
            public void done(ParseException e) {
              if (isActivityDestroyed()) {
                Log.e(LOG_TAG, "Activity was destroyed during sign up");
                return;
              }

              loadingFinish();
              if (e == null) {
                signUpSuccess(user);
              } else {
                switch (e.getCode()) {
                  case ParseException.INVALID_EMAIL_ADDRESS:
                    showSnack(R.string.com_parse_ui_invalid_email_toast);
                    break;
                  case ParseException.USERNAME_TAKEN:
                    showSnack(R.string.com_parse_ui_username_taken_toast);
                    break;
                  case ParseException.EMAIL_TAKEN:
                    showSnack(R.string.com_parse_ui_email_taken_toast);
                    break;
                  default:
                    Log.e(LOG_TAG, "Error signing up " + mEmailAddress + ": " + e.toString());
                    showSnack(R.string.com_parse_ui_signup_failed_unknown_toast);
                }
              }
            }
          });
    }
  }