MenuApplication/app/src/main/java/com/example/a64/menuapplication/LoginActivity.java
private void attemptLogin() {
        if (mAuthTask != null) {
            return;
        }

        // Reset errors.
        mEmailView.setError(null);
        mPasswordView.setError(null);

        // Store values at the time of the login attempt.
        String email = mEmailView.getText().toString();
        String password = mPasswordView.getText().toString();

        boolean cancel = false;
        View focusView = null;

        // Check for a valid password, if the user entered one.
        if (!TextUtils.isEmpty(password) && !isPasswordValid(password)) {
            mPasswordView.setError(getString(R.string.error_invalid_password));
            focusView = mPasswordView;
            cancel = true;
        }

        // Check for a valid email address.
        if (TextUtils.isEmpty(email)) {
            mEmailView.setError(getString(R.string.error_field_required));
            focusView = mEmailView;
            cancel = true;
        } else if (!isEmailValid(email)) {
            mEmailView.setError(getString(R.string.error_invalid_email));
            focusView = mEmailView;
            cancel = true;
        }

        if (cancel) {
            // There was an error; don't attempt login and focus the first
            // form field with an error.
            focusView.requestFocus();
        } else {
            // Show a progress spinner, and kick off a background task to
            // perform the user login attempt.
            showProgress(true);
            mAuthTask = new UserLoginTask();
            mAuthTask.execute(email, password);
        }
    }
/**
     * Attempts to sign in or register the account specified by the login form.
     * If there are form errors (invalid email, missing fields, etc.), the
     * errors are presented and no actual login attempt is made.
     */
Attempts to sign in or register the account specified by the login form.
If there are form errors (invalid email, missing fields, etc.), the
errors are presented and no actual login attempt is made.
Attempts to sign in or register the account specified by the login form . If there are form errors ( invalid email missing fields etc . ) the errors are presented and no actual login attempt is made .
private void attemptLogin() {
        if (mAuthTask != null) {
            return;
        }
        mEmailView.setError(null);
        mPasswordView.setError(null);
        String email = mEmailView.getText().toString();
        String password = mPasswordView.getText().toString();
        boolean cancel = false;
        View focusView = null;
        if (!TextUtils.isEmpty(password) && !isPasswordValid(password)) {
            mPasswordView.setError(getString(R.string.error_invalid_password));
            focusView = mPasswordView;
            cancel = true;
        }
        if (TextUtils.isEmpty(email)) {
            mEmailView.setError(getString(R.string.error_field_required));
            focusView = mEmailView;
            cancel = true;
        } else if (!isEmailValid(email)) {
            mEmailView.setError(getString(R.string.error_invalid_email));
            focusView = mEmailView;
            cancel = true;
        }
        if (cancel) {
            focusView.requestFocus();
        } else {
            showProgress(true);
            mAuthTask = new UserLoginTask();
            mAuthTask.execute(email, password);
        }
    }
private void attemptLogin ( ) { if ( mAuthTask != null ) { return ; } mEmailView . setError ( null ) ; mPasswordView . setError ( null ) ; String email = mEmailView . getText ( ) . toString ( ) ; String password = mPasswordView . getText ( ) . toString ( ) ; boolean cancel = false ; View focusView = null ; if ( ! TextUtils . isEmpty ( password ) && ! isPasswordValid ( password ) ) { mPasswordView . setError ( getString ( R . string . error_invalid_password ) ) ; focusView = mPasswordView ; cancel = true ; } if ( TextUtils . isEmpty ( email ) ) { mEmailView . setError ( getString ( R . string . error_field_required ) ) ; focusView = mEmailView ; cancel = true ; } else if ( ! isEmailValid ( email ) ) { mEmailView . setError ( getString ( R . string . error_invalid_email ) ) ; focusView = mEmailView ; cancel = true ; } if ( cancel ) { focusView . requestFocus ( ) ; } else { showProgress ( true ) ; mAuthTask = new UserLoginTask ( ) ; mAuthTask . execute ( email , password ) ; } }
Attempts to sign in or register the account specified by the login form.
Attempts to sign in or register the account specified by the login form .
// Reset errors. // Store values at the time of the login attempt. // Check for a valid password, if the user entered one. // Check for a valid email address. // There was an error; don't attempt login and focus the first // form field with an error. // Show a progress spinner, and kick off a background task to // perform the user login attempt.