Ejemplo n.º 1
0
  @Override
  public void initData() {

    btnLogin.setOnClickListener(this);
    btnRegister.setOnClickListener(this);

    txtForgetPwd.setOnClickListener(this);

    if (SPManager.retriveBoolean(SPManager.KEY_IS_CHECKED)) {

      checkBox.setChecked(true);

      edit_email_phone.setText(SPManager.retrive(SPManager.KEY_USERNAME));
      editPassword.setText(SPManager.retrive(SPManager.KEY_PASSWORD));
    }
    gcmId = SPManager.retrive(SPManager.KEY_GCM_REG_ID);

    if (gcmId == null) {

      registerForGcm();

    } else {

      dLog("GCM is registered " + gcmId);
    }
  }
Ejemplo n.º 2
0
  @Override
  public void onError(String error) {

    SPManager.delete(SPManager.KEY_GCM_REG_ID);

    eLog("Error in GCM Registration " + error);
  }
Ejemplo n.º 3
0
  @Override
  public void onPostRegister(String registeredId) {

    gcmId = registeredId;
    dLog("Registration Id " + gcmId);

    SPManager.save(SPManager.KEY_GCM_REG_ID, gcmId);
  }
Ejemplo n.º 4
0
  @Override
  public void onClick(View v) {

    switch (v.getId()) {
      case R.id.btn_login:
        edit_email_phone.setError(null);
        editPassword.setError(null);

        passsword = editPassword.getText().toString();

        if (validate()) {

          if (passsword.length() > 0) {

            if (checkBox.isChecked()) {

              SPManager.saveBoolean(SPManager.KEY_IS_CHECKED, checkBox.isChecked());
              SPManager.save(SPManager.KEY_USERNAME, emailMobile);
              SPManager.save(SPManager.KEY_PASSWORD, passsword);
            } else {

              SPManager.delete(SPManager.KEY_IS_CHECKED);
            }

            if (isDeviceConnected()) {

              if (SPManager.retrive(SPManager.KEY_GCM_REG_ID) != null) {

                if (gcmId != null) {

                  callLoginWebservice(emailMobile, passsword);
                } else {
                  smallToast("Gcm Registration Error try again latter !!!");
                  registerForGcm();
                }

              } else {

              }

            } else {

              smallToast(getString(R.string.errorNoInternet));
            }

          } else {

            editPassword.setError("Invalid Password");
            editPassword.requestFocus();
          }
        }
        break;
      case R.id.btnRegister:
        Intent intent = new Intent(LoginActivity.this, RegisterActivity.class);

        startActivity(intent);
        break;
      case R.id.txtForgetPwd:
        DialogFragment dialogFragment = new DialogFragment(false, this);
        dialogFragment.show(getSupportFragmentManager(), "ResetPassword");

        break;

      default:
        break;
    }
  }