Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialJavier Alvarado
16,060 PointsError message takes a long time to load
For some reason, the error message that's supposed to display when the email is invalid takes a long time to load (about 15 seconds), whereas in the video the message pops up instantly. My code is posted below. What can I do to make it instant like the video?
public class SignUpActivity extends ActionBarActivity {
protected EditText mUsername;
protected EditText mEmail;
protected EditText mPassword;
protected Button mSignupButton;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_sign_up);
mUsername = (EditText)findViewById(R.id.usernameField);
mEmail = (EditText)findViewById(R.id.emailField);
mPassword = (EditText)findViewById(R.id.passwordField);
mSignupButton = (Button)findViewById(R.id.signupButton);
mSignupButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String username = mUsername.getText().toString();
String email = mEmail.getText().toString();
String password = mPassword.getText().toString();
username = username.trim();
password = password.trim();
email = email.trim();
if (username.isEmpty() || email.isEmpty() || password.isEmpty()) {
AlertDialog.Builder builder = new AlertDialog.Builder(SignUpActivity.this);
builder.setMessage("Please make sure you enter a username, email, and password.")
.setTitle("Error!")
.setPositiveButton(android.R.string.ok, null);
AlertDialog dialog = builder.create();
dialog.show();
} else {
//create new user!
ParseUser newUser = new ParseUser();
newUser.setUsername(username);
newUser.setEmail(email);
newUser.setPassword(password);
newUser.signUpInBackground(new SignUpCallback() {
@Override
public void done(ParseException e) {
if (e == null) {
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("Error!")
.setPositiveButton(android.R.string.ok, null);
AlertDialog dialog = builder.create();
dialog.show();
}
}
});
}
}
});
}
Javier Alvarado
16,060 PointsJavier Alvarado
16,060 PointsIs it possibly a problem with Parse.com and not my code? I tried copying and pasting Ben's code starting from the declaration of the different elements down to the end of the onCreate() method and It still takes awhile for the error to pop up. Or could it be the emulator? I'm using Genymotion to test the app right now.