private boolean verifyInputs(String email, String password, String repassword) {
   if (TextUtils.isEmpty(email)) {
     ViewAnimation.blink(this, ed_email);
     Crouton.cancelAllCroutons();
     AppSnackBar.showTopSnackbar(this, getString(R.string.BR_SIGN_005), Color.RED, Color.WHITE);
     return false;
   } else if (!mValidator.isValidEmail(email)) {
     ViewAnimation.blink(this, ed_email);
     Crouton.cancelAllCroutons();
     AppSnackBar.showTopSnackbar(this, getString(R.string.BR_GNL_002), Color.RED, Color.WHITE);
     return false;
   } else if (TextUtils.isEmpty(password)) {
     ViewAnimation.blink(this, ed_new_password);
     Crouton.cancelAllCroutons();
     AppSnackBar.showTopSnackbar(this, getString(R.string.BR_SIGN_002), Color.RED, Color.WHITE);
     return false;
   } else if (!mValidator.isValidPassword(password)) {
     ViewAnimation.blink(this, ed_new_password);
     Crouton.cancelAllCroutons();
     AppSnackBar.showTopSnackbar(this, getString(R.string.BR_GNL_003), Color.RED, Color.WHITE);
     return false;
   } else if (TextUtils.isEmpty(repassword)) {
     ViewAnimation.blink(this, ed_repassword);
     Crouton.cancelAllCroutons();
     AppSnackBar.showTopSnackbar(this, getString(R.string.BR_SIGN_003), Color.RED, Color.WHITE);
     return false;
   } else if (!mValidator.isPasswordsMatched(password, repassword)) {
     ViewAnimation.blink(this, ed_new_password);
     ViewAnimation.blink(this, ed_repassword);
     Crouton.cancelAllCroutons();
     AppSnackBar.showTopSnackbar(this, getString(R.string.BR_SIGN_006), Color.RED, Color.WHITE);
     return false;
   }
   return true;
 }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_forget_password);
    iv_logo = (ImageView) this.findViewById(R.id.iv_logo);
    img_background = (ImageView) this.findViewById(R.id.img_background);
    resizeLogo();
    fontManager = FontManager.getInstance(getAssets());
    ed_email = (EditText) this.findViewById(R.id.ed_email);
    ed_email
        .getBackground()
        .setColorFilter(getResources().getColor(R.color.ed_underline), PorterDuff.Mode.SRC_ATOP);
    ed_new_password = (EditText) this.findViewById(R.id.ed_new_password);
    ed_new_password
        .getBackground()
        .setColorFilter(getResources().getColor(R.color.ed_underline), PorterDuff.Mode.SRC_ATOP);
    ed_repassword = (EditText) this.findViewById(R.id.ed_repassword);
    ed_repassword
        .getBackground()
        .setColorFilter(getResources().getColor(R.color.ed_underline), PorterDuff.Mode.SRC_ATOP);

    ed_email.setTypeface(fontManager.getFont(FontManager.ROBOTO_LIGHT));
    ed_new_password.setTypeface(fontManager.getFont(FontManager.ROBOTO_LIGHT));
    ed_repassword.setTypeface(fontManager.getFont(FontManager.ROBOTO_LIGHT));

    btn_update_password = (Button) this.findViewById(R.id.btn_update_password);
    btn_update_password = (Button) this.findViewById(R.id.btn_update_password);
    btn_update_password.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            String email = ed_email.getText().toString().trim();
            String password = ed_new_password.getText().toString();
            String repassword = ed_repassword.getText().toString();
            if (verifyInputs(email, password, repassword)) {
              v.startAnimation(animFade);
              update_password(email, password);
            }
          }
        });
    btn_update_password.setTypeface(fontManager.getFont(FontManager.ROBOTO_MEDIUM));
    iv_back = (ImageView) this.findViewById(R.id.iv_back);
    iv_back.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            onBackPressed();
          }
        });
    ll_parent = (CoordinatorLayout) this.findViewById(R.id.ll_parent);
    ll_parent.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            hideSoftKeyboard();
          }
        });
    mValidator = Validator.getInstance();
    animFade = AnimationUtils.loadAnimation(ForgetPassword.this, R.anim.fade);
  }
Пример #3
0
  private void initializeFields() {
    fontManager = FontManager.getInstance(getAssets());
    pref =
        getSharedPreferences(GNLConstants.SharedPreference.SHARED_PREF_NAME, Context.MODE_PRIVATE);
    prefEditor = pref.edit();
    iv_logo = (ImageView) this.findViewById(R.id.iv_logo);
    img_background = (ImageView) this.findViewById(R.id.img_background);
    ed_fname = (EditText) this.findViewById(R.id.ed_fname);
    ed_fname
        .getBackground()
        .setColorFilter(getResources().getColor(R.color.ed_underline), PorterDuff.Mode.SRC_ATOP);
    ed_lname = (EditText) this.findViewById(R.id.ed_lname);
    ed_lname
        .getBackground()
        .setColorFilter(getResources().getColor(R.color.ed_underline), PorterDuff.Mode.SRC_ATOP);
    ed_email = (EditText) this.findViewById(R.id.ed_email);
    ed_email
        .getBackground()
        .setColorFilter(getResources().getColor(R.color.ed_underline), PorterDuff.Mode.SRC_ATOP);
    ed_password = (EditText) this.findViewById(R.id.ed_password);
    ed_password
        .getBackground()
        .setColorFilter(getResources().getColor(R.color.ed_underline), PorterDuff.Mode.SRC_ATOP);
    ed_repassword = (EditText) this.findViewById(R.id.ed_repassword);
    ed_repassword
        .getBackground()
        .setColorFilter(getResources().getColor(R.color.ed_underline), PorterDuff.Mode.SRC_ATOP);

    ed_fname.setTypeface(fontManager.getFont(FontManager.ROBOTO_LIGHT));
    ed_lname.setTypeface(fontManager.getFont(FontManager.ROBOTO_LIGHT));
    ed_email.setTypeface(fontManager.getFont(FontManager.ROBOTO_LIGHT));
    ed_password.setTypeface(fontManager.getFont(FontManager.ROBOTO_LIGHT));
    ed_repassword.setTypeface(fontManager.getFont(FontManager.ROBOTO_LIGHT));

    btn_signup = (Button) this.findViewById(R.id.btn_signup);
    btn_signup.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            fname = ed_fname.getText().toString().trim();
            lname = ed_lname.getText().toString().trim();
            email = ed_email.getText().toString().trim();
            password = ed_password.getText().toString();
            repassword = ed_repassword.getText().toString();
            if (verifyInputs(fname, lname, email, password, repassword)) {
              v.startAnimation(animFade);
              register(fname, lname, email, password);
            }
          }
        });
    btn_signup.setTypeface(fontManager.getFont(FontManager.ROBOTO_MEDIUM));
    iv_back = (ImageView) this.findViewById(R.id.iv_back);
    iv_back.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            onBackPressed();
          }
        });
    ll_parent = (CoordinatorLayout) this.findViewById(R.id.ll_parent);
    ll_parent.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            hideSoftKeyboard();
          }
        });
    mValidator = Validator.getInstance();
    animFade = AnimationUtils.loadAnimation(Register.this, R.anim.fade);
  }