示例#1
0
  public void releaseLocationLocke(String releaseBy) throws BaseException {

    userFunctionsImpl.releaseLocationLocke(this, releaseBy);
  }
示例#2
0
  public void openUserLock(String openBy) throws BaseException {

    userFunctionsImpl.openUserLock(this, openBy);
  }
示例#3
0
 public void setRawPassword(String rawPassword) {
   this.password = userFunctionsImpl.encodePassword(rawPassword);
 }
示例#4
0
  public void changePassword(
      String oldPassword, String newPassword, String newPassword2, String changeBy)
      throws BaseException {

    userFunctionsImpl.changePassword(this, oldPassword, newPassword, newPassword2, changeBy);
  }
    public void onClick(View v) {
      String email = edtMail.getText().toString();
      String password = edtPassword.getText().toString();
      String nama = edtNama.getText().toString();
      String alamat = edtAlamat.getText().toString();
      String no_telp = edtTelp.getText().toString();
      EmailValidator emailValidator = new EmailValidator();

      nu = new NetworkUtil(getApplicationContext());
      isInternetDetect = nu.isConnectingToInternet();

      if (isInternetDetect) {

        if (emailValidator.validate(email)) {
          UserFunctions userFunction = new UserFunctions();
          JSONObject json = userFunction.registerUser(email, password, nama, alamat, no_telp);

          try {
            if (json.getString(KEY_SUCCESS) != null) {
              String res = json.getString(KEY_SUCCESS);
              if (Integer.parseInt(res) == 1) {
                DatabaseHandler db = new DatabaseHandler(getApplicationContext());
                JSONObject json_user = json.getJSONObject("user");

                userFunction.logoutUser(getApplicationContext());
                db.addUser(
                    json_user.getString(KEY_NAMA),
                    json_user.getString(KEY_EMAIL),
                    json_user.getString(KEY_UID),
                    json_user.getString(KEY_REGISTER_DATE));

                Intent login = new Intent(getApplicationContext(), LoginActivity.class);
                login.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                startActivity(login);

                Toast.makeText(
                        v.getContext(),
                        "Registrasi telah berhasil, silahkan login.",
                        Toast.LENGTH_SHORT)
                    .show();

                finish();
              } else {
                Toast.makeText(
                        v.getContext(),
                        "Terjadi kesalahan pada saat registrasi.",
                        Toast.LENGTH_SHORT)
                    .show();
              }
            }
          } catch (NullPointerException e) {
            showMessageError(
                RegisterActivity.this,
                "Koneksi ke server gagal.",
                "Pastikan anda terkoneksi dengan internet.",
                false);
          } catch (JSONException e) {
            e.printStackTrace();
          }

        } else {
          Toast.makeText(v.getContext(), "Format E-mail tidak sesuai.", Toast.LENGTH_SHORT).show();
        }

      } else {
        showAlertDialog(
            RegisterActivity.this, "Internet Connection", "Koneksi ke server gagal.", false);
      }
    }