Created
March 28, 2015 03:05
-
-
Save edwardinubuntu/fa7e2e2ffa0e12d6c5bf to your computer and use it in GitHub Desktop.
User Login
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
final TextView userErrorTextView = (TextView)rootView.findViewById(R.id.user_login_exception_text_view); | |
rootView.findViewById(R.id.user_login_button).setOnClickListener(new View.OnClickListener() { | |
@Override | |
public void onClick(View v) { | |
if (userIdLoginEditText.getText() != null | |
&& userIdLoginEditText.getText().length() > 0 | |
&& userPasswordLoginEditText.getText() != null | |
&& userPasswordLoginEditText.getText().length() > 0) { | |
InputMethodManager imm = (InputMethodManager)getActivity().getSystemService( | |
Context.INPUT_METHOD_SERVICE); | |
imm.hideSoftInputFromWindow(userPasswordLoginEditText.getWindowToken(), 0); | |
userErrorTextView.setText(null); | |
updateRefreshItem(true); | |
ParseUser.logInInBackground(userIdLoginEditText.getText().toString(), | |
userPasswordLoginEditText.getText().toString(), new LogInCallback() { | |
@Override | |
public void done(ParseUser parseUser, ParseException e) { | |
updateRefreshItem(false); | |
if (parseUser != null) { | |
// Hooray! The user logged in. | |
Toast.makeText(getActivity(), getResources().getText(R.string.action_username_login_success), Toast.LENGTH_SHORT).show(); | |
putNeedUpdate(); | |
getActivity().setResult(Activity.RESULT_OK); | |
getActivity().finish(); | |
} else { | |
// Sign up failed. | |
userErrorTextView.setText(e.getLocalizedMessage()); | |
} | |
} | |
}); | |
} else { | |
Toast.makeText(getActivity(), getResources().getText(R.string.action_login_form_validate_failure), Toast.LENGTH_SHORT).show(); | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment