Android Open Source - ribbit Sign Up Activity






From Project

Back to project page ribbit.

License

The source code is released under:

MIT License

If you think the Android project ribbit listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.lleshiart.ribbit;
// ww  w.j  a v  a 2s . com
import android.app.Activity;
import android.app.AlertDialog;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.widget.Button;
import android.widget.EditText;

import com.parse.ParseException;
import com.parse.ParseUser;
import com.parse.SignUpCallback;

public class SignUpActivity extends Activity {
  
  protected EditText mFirstName;
  protected EditText mLastName;
  protected EditText mUsername;
  protected EditText mPassword;
  protected EditText mEmail;
  protected EditText mWebsite;
  protected Button mSignUpButton;

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
    setContentView(R.layout.activity_sign_up);

    mFirstName = (EditText)findViewById(R.id.firstNameField);
    mLastName = (EditText)findViewById(R.id.lastNameField);
    mUsername = (EditText)findViewById(R.id.usernameField);
    mPassword = (EditText)findViewById(R.id.passwordField);
    mEmail = (EditText)findViewById(R.id.emailField);
    mWebsite = (EditText)findViewById(R.id.websiteField);
    mSignUpButton = (Button)findViewById(R.id.signupButton);
    mSignUpButton.setOnClickListener(new View.OnClickListener() {
      
      @Override
      public void onClick(View v) {
        String firstName = mFirstName.getText().toString();
        String lastName = mLastName.getText().toString();
        String username =  mUsername.getText().toString();
        String password =  mPassword.getText().toString();
        String email =  mEmail.getText().toString();
        String website = mWebsite.getText().toString();
        
        username = username.trim();
        password = password.trim();
        email = email.trim();
        
        if (username.isEmpty() || password.isEmpty() || email.isEmpty()) {
          AlertDialog.Builder builder = new AlertDialog.Builder(SignUpActivity.this);
          builder.setMessage(R.string.signup_error_message)
            
            .setTitle(R.string.signup_error_title)
            .setPositiveButton(android.R.string.ok, null);
          AlertDialog dialog = builder.create();
          dialog.show();
        }
        else {
          setProgressBarIndeterminateVisibility(true);
          
          // create the new user
          ParseUser newUser = new ParseUser();
          newUser.setUsername(username);
          newUser.setPassword(password);
          newUser.setEmail(email);
          // Optional fields
          newUser.put(ParseConstants.KEY_FIRST_NAME, firstName);
          newUser.put(ParseConstants.KEY_LAST_NAME, lastName);
          newUser.put(ParseConstants.KEY_WEBSITE, website);
          
          newUser.signUpInBackground(new SignUpCallback() {
            
            @Override
            public void done(ParseException e) {
              setProgressBarIndeterminateVisibility(false);
              
              if (e == null) {
                // Success!
                Intent intent = new Intent(SignUpActivity.this, MainActivity.class);
                intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
                startActivity(intent);
              }
              else {
                AlertDialog.Builder builder = new AlertDialog.Builder(SignUpActivity.this);
                builder.setMessage(e.getMessage())
                  
                  .setTitle(R.string.signup_error_title)
                  .setPositiveButton(android.R.string.ok, null);
                AlertDialog dialog = builder.create();
                dialog.show();
              }
            }
          });
        }
      }
    });
    
  }

}




Java Source Code List

com.lleshiart.ribbit.EditFriendsActivity.java
com.lleshiart.ribbit.FileHelper.java
com.lleshiart.ribbit.ForgotPasswordActivity.java
com.lleshiart.ribbit.FriendsFragment.java
com.lleshiart.ribbit.ImageResizer.java
com.lleshiart.ribbit.InboxFragment.java
com.lleshiart.ribbit.LoginActivity.java
com.lleshiart.ribbit.MainActivity.java
com.lleshiart.ribbit.MessageAdapter.java
com.lleshiart.ribbit.NewMessageActivity.java
com.lleshiart.ribbit.ParseConstants.java
com.lleshiart.ribbit.RecipientsActivity.java
com.lleshiart.ribbit.SectionsPagerAdapter.java
com.lleshiart.ribbit.SignUpActivity.java
com.lleshiart.ribbit.ViewImageActivity.java