本文整理匯總了Java中com.parse.ParseUser.put方法的典型用法代碼示例。如果您正苦於以下問題:Java ParseUser.put方法的具體用法?Java ParseUser.put怎麽用?Java ParseUser.put使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.parse.ParseUser
的用法示例。
在下文中一共展示了ParseUser.put方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: doInBackground
import com.parse.ParseUser; //導入方法依賴的package包/類
@Override
protected Bundle doInBackground(Bundle... bundles) {
Bundle bundle = bundles[0];
ParseUser currentUser = ParseUser.getCurrentUser();
if (bundle.getString(ParseTables.Users.NAME) != null) {
currentUser.put(ParseTables.Users.NAME, bundle.getString(ParseTables.Users.NAME));
}
if (bundle.getString(ParseTables.Users.EMAIL) != null) {
currentUser.put(ParseTables.Users.EMAIL, bundle.getString(ParseTables.Users.EMAIL));
currentUser.setUsername(bundle.getString(ParseTables.Users.EMAIL));
}
if (bundle.getString(ParseTables.Users.DOB) != null) {
currentUser.put(ParseTables.Users.DOB, bundle.getString(ParseTables.Users.DOB));
}
try {
if (currentUser.getSessionToken() != null) {
currentUser.save();
} else {
currentUser.setPassword("todoGenerateARandomString");
currentUser.signUp();
}
} catch (ParseException e) {
e.printStackTrace();
}
return bundle;
}
示例2: signup
import com.parse.ParseUser; //導入方法依賴的package包/類
private void signup(String usernametxt, String passwordtxt) {
if (!isEmpty()){
int numberParse = 0;
ParseQuery<ParseUser> numberofUsers = ParseUser.getQuery(); // Note to myself : count users in parse class
try {
numberParse=numberofUsers.count();
} catch (ParseException e1) {
e1.printStackTrace();
}
user = new ParseUser();
user.setUsername(usernametxt);
user.setPassword(passwordtxt);
user.put("userID",numberParse+1);
user.signUpInBackground(new SignUpCallback() {
public void done(ParseException e) {
checkSignup(e);
}
});
}
}
示例3: create
import com.parse.ParseUser; //導入方法依賴的package包/類
public void create(User user) {
Log.d("User", "start method create in UserCRUD");
ParseUser usr = new ParseUser();
usr.put(USERNAME, user.getUsername());
usr.put(PASSWORD, user.getPassword());
usr.put(EMAIL, user.getEmail());
Log.d("User", user.getUsername());
usr.signUpInBackground(new SignUpCallback() {
@Override
public void done(ParseException e) {
if (e == null) {
Log.d("User", "h send empty message");
handler.sendEmptyMessage(CONNECTION_OK);
Log.d("User", "h = 1");
} else {
handler.sendEmptyMessage(0);
Log.d("User", "exception" + e.toString());
}
}
});
}
示例4: createAccount
import com.parse.ParseUser; //導入方法依賴的package包/類
@OnClick(R.id.saveNewAccount) void createAccount(View view) {
ParseUser parseUser = new ParseUser();
parseUser.setUsername(newUser.getText().toString());
parseUser.setEmail(newUser.getText().toString());
parseUser.setPassword(newPassword.getText().toString());
parseUser.put(Constants.PARSE_USER_ATTR_NAME, newName.getText().toString().trim());
parseUser.signUpInBackground(new SignUpCallback() {
public void done(ParseException e) {
if (e == null) {
// Hooray! Let them use the app now.
Log.e(LOG_TAG, "Hooray! Let them use the app now");
Toast.makeText(getApplicationContext(), "Hooray! Let them use the app now", Toast.LENGTH_SHORT).show();
handleAccountCreated();
} else {
// Sign up didn't succeed. Look at the ParseException
// to figure out what went wrong
Log.e(LOG_TAG, "Sign up didn't succeed. Look at the ParseException");
Toast.makeText(getApplicationContext(), "Sign up didn't succeed. Look at the ParseException", Toast.LENGTH_SHORT).show();
}
}
});
}
示例5: onSharedPreferenceChanged
import com.parse.ParseUser; //導入方法依賴的package包/類
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
if (key.equals("pref_distance")) {
Preference pref = findPreference(key);
pref.setSummary(sharedPreferences.getString(key, ""));
ParseUser pu = ParseUser.getCurrentUser();
Log.d("SETTINGS", sharedPreferences.getString(key, "100"));
pu.put("distance", Float.parseFloat(sharedPreferences.getString(key, "100"))/1000.0);
pu.saveEventually();
}
}
示例6: onStartCommand
import com.parse.ParseUser; //導入方法依賴的package包/類
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
super.onStartCommand(intent, flags, startId);
Log.e("Network Loc Service", "Service running");
AlarmManager am = (AlarmManager)getSystemService(Context.ALARM_SERVICE);
Calendar timeOff9 = Calendar.getInstance();
Intent intent2 = new Intent(this,MyReceiver.class);
PendingIntent sender = PendingIntent.getBroadcast(this, 0, intent2,
PendingIntent.FLAG_UPDATE_CURRENT);
am.set(AlarmManager.RTC_WAKEUP, timeOff9.getTimeInMillis() + 55000, sender);
ParseGeoPoint pt = new ParseGeoPoint(getLocation().getLatitude(),getLocation().getLongitude());
ParseUser person = ParseUser.getCurrentUser();
if(person==null)
{
stopSelf();
return 0;
}
person.put("Geolocation",pt);
person.saveInBackground();
return START_STICKY;
}
示例7: signup
import com.parse.ParseUser; //導入方法依賴的package包/類
/**
* Creates a new user in the Parse backend using the provided credentials
*
* @param teamNumber the team number to signup to
* @param email the email of the user
* @param pass the password of the user account
*/
public void signup(final String teamNumber, final String email, String pass, final View view) {
if (!isNetworkAvailable()) {
Snackbar.make(view, "Unable to connect to the Internet. Try again.", Snackbar.LENGTH_SHORT).show();
return;
}
// Make sure all fields are filled in
if (teamNumber.equals("") || email.equals("") || pass.equals("")) {
Snackbar.make(view, "Please fill in all fields.", Snackbar.LENGTH_SHORT).show();
return;
}
// Create new ParseUser object to signup with field credentials
ParseUser user = new ParseUser();
user.setEmail(email);
user.setUsername(email);
user.setPassword(pass);
user.put("Team", teamNumber);
user.signUpInBackground(new SignUpCallback() {
@Override
public void done(ParseException e) {
// Signup was successful, no exception
if (e == null) {
Snackbar.make(view, "Successfully signed up.", Snackbar.LENGTH_SHORT).show();
sessionManager.createLoginSession(teamNumber, email);
startActivity(new Intent(getApplicationContext(), TeamListActivity.class));
finish();
} else {
Snackbar.make(view, "Unable signed up. Please try again.", Snackbar.LENGTH_SHORT).show();
password.setText("");
passwordAgain.setText("");
}
}
});
}
示例8: signup
import com.parse.ParseUser; //導入方法依賴的package包/類
public void signup() {
final Intent myintent = new Intent(getActivity(),HomePage.class);
if (!name.getText().toString().isEmpty() && !email.getText().toString().isEmpty() && !pass.getText().toString().isEmpty() && !repass.getText().toString().isEmpty() && pass.getText().toString().equals(repass.getText().toString()) && pass.getText().toString().length() >= 6)
{
ParseUser user = new ParseUser();
user.setUsername(email.getText().toString());
user.setPassword(pass.getText().toString());
user.setEmail(email.getText().toString());
user.put("Name",name.getText().toString());
user.signUpInBackground(new SignUpCallback() {
public void done(ParseException e) {
if (e == null) {
showSuccess("Please verify your email, then click the login button");
firebaseSignUp(email.getText().toString());
} else {
showIssue(e.toString());
}
}
});
}else if (name.getText().toString().isEmpty() || email.getText().toString().isEmpty() || pass.getText().toString().isEmpty() || repass.getText().toString().isEmpty()){
showIssue("Please makes sure you fill out all the fields properly!");
}else if(!pass.getText().toString().equals(repass.getText().toString())){
showIssue("Oops your passwords do not match, please try again");
}else if(pass.getText().toString().length()<6){
showIssue("Please make sure your password is at least six characters long");
}
}
示例9: addTagToUser
import com.parse.ParseUser; //導入方法依賴的package包/類
private void addTagToUser(String tag){
ParseUser user = ParseUser.getCurrentUser();
List<String> tags = user.getList("tags");
if (tags == null) tags = new ArrayList<>();
if(!tags.contains(tag)) {
if(tags.size()>= ConnectedConstants.MAX_NOTIFICATION_TAGS){
Toast.makeText(getActivity(), String.format("You can only subscribe to %d tags", ConnectedConstants.MAX_NOTIFICATION_TAGS), Toast.LENGTH_SHORT).show();
return;
}
tags.add(tag);
user.put("tags", tags);
user.saveInBackground();
}
}
示例10: removeTagFromUser
import com.parse.ParseUser; //導入方法依賴的package包/類
private void removeTagFromUser(String tag){
ParseUser user = ParseUser.getCurrentUser();
List<String> tags = user.getList("tags");
if (tags == null) tags = new ArrayList<>();
tags.remove(tag);
user.put("tags", tags);
user.saveInBackground();
}
示例11: onSharedPreferenceChanged
import com.parse.ParseUser; //導入方法依賴的package包/類
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
//Update a preference's summary as soon as a user changes it
Preference pref = findPreference(key);
if(key.equals(getString(R.string.prefs_notification_sound_key))){
Uri ringtoneUri = Uri.parse(sharedPreferences.getString(key, ""));
Ringtone ringtone = RingtoneManager.getRingtone(getActivity(), ringtoneUri);
String name = ringtone.getTitle(getActivity());
RingtonePreference ringtonePref = (RingtonePreference) findPreference(key);
ringtonePref.setSummary(name);
}else if(key.equals(getString(R.string.prefs_notification_resend_toggle_key))){
}else if(key.equals(getString(R.string.prefs_notification_resend_delay_key))){
}else if(key.equals(getString(R.string.prefs_display_name_key))){
String newName = ((EditTextPreference) pref).getText().trim();
if(newName.equals("")){//override
((EditTextPreference) pref).setText(defaultFName);
Toast.makeText(getActivity(), R.string.str_blank_name_msg, Toast.LENGTH_SHORT).show();
}
else {
defaultFName = newName;
pref.setSummary(newName);
ParseUser u = ParseUser.getCurrentUser();
u.put("friendlyName", newName);
u.saveInBackground();
}
}else if(key.equals(getString(R.string.prefs_clear_pings_key))){
//will not run
}
}
示例12: setCurrentLatLng
import com.parse.ParseUser; //導入方法依賴的package包/類
public void setCurrentLatLng(@Nullable LatLng currentLatLng) {
boolean shouldPostEvent = false;
if (this.currentLatLng == null && currentLatLng != null) {
shouldPostEvent = true;
}
if (currentLatLng == null) {
UserPreferences.setLatitude(Event.INVALID_LOCATION);
UserPreferences.setLongitude(Event.INVALID_LOCATION);
} else {
if (LoginManager.getInstance().isLoggedIn()) {
if (this.currentLatLng == null ||
distance((float) this.currentLatLng.latitude, (float) this.currentLatLng.longitude,
(float) currentLatLng.latitude, (float) currentLatLng.longitude) > DISTANCE_THRESHOLD) {
// If we don't have a current latlng yet, or if the new received distance is from a distance greater than the threshold, update
// ParseUser object and UserPreferences
UserPreferences.setLatitude(currentLatLng.latitude);
UserPreferences.setLongitude(currentLatLng.longitude);
final double previousLatitude = this.currentLatLng != null ? this.currentLatLng.latitude : Event.INVALID_LOCATION;
final double previousLongitude = this.currentLatLng != null ? this.currentLatLng.longitude : Event.INVALID_LOCATION;
ParseUser currentUser = ParseUser.getCurrentUser();
currentUser.put("location", new ParseGeoPoint(currentLatLng.latitude, currentLatLng.longitude));
currentUser.saveInBackground(new SaveCallback() {
@Override
public void done(ParseException e) {
if (e != null) {
// Something bad occurred. Rollback UserPreferences
UserPreferences.setLatitude(previousLatitude);
UserPreferences.setLongitude(previousLongitude);
Timber.d("Rolling back saved locations in UserPreferences because could not get it saved in Parse.");
}
}
});
}
} else {
UserPreferences.setLatitude(currentLatLng.latitude);
UserPreferences.setLongitude(currentLatLng.longitude);
}
}
this.currentLatLng = currentLatLng;
if (shouldPostEvent) {
// Only post event after this..currentLatLng has the right value
EventBus.getDefault().post(new FirstLocationEncounteredEvent());
}
}
示例13: run
import com.parse.ParseUser; //導入方法依賴的package包/類
@Override
public void run() {
try {
Log.d(TAG, "starting download pictures thread");
ParseUser currentUser = ParseUser.getCurrentUser();
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
SharedPreferences.Editor editor = prefs.edit();
String coverPhotoUrl = photosFetcher.downloadCoverPhoto();
editor.putString(ParseTables.KEY_COVER_URL, coverPhotoUrl);
Bitmap coverPhoto = Utilities.downloadBitmap(coverPhotoUrl);
Log.d(TAG, "Downloaded cover photo");
String profilePhotoUrl = photosFetcher.downloadProfilePhoto();
editor.putString(ParseTables.KEY_IMAGE_URL, profilePhotoUrl);
Bitmap profilePhoto = Utilities.downloadBitmap(profilePhotoUrl);
Log.d(TAG, "downloaded profile photo");
// Compress image to lower quality scale 1 - 100
if (coverPhoto != null) {
ByteArrayOutputStream coverPhotoStream = new ByteArrayOutputStream();
coverPhoto.compress(Bitmap.CompressFormat.PNG, 80, coverPhotoStream);
byte[] profilePhotoBytes = coverPhotoStream.toByteArray();
ParseFile profilePhotoFile = new ParseFile("coverPicture.png", profilePhotoBytes);
profilePhotoFile.save();
currentUser.put(ParseTables.Users.COVER, profilePhotoFile);
}
if (profilePhoto != null) {
ByteArrayOutputStream profilePhotoStream = new ByteArrayOutputStream();
profilePhoto.compress(Bitmap.CompressFormat.PNG, 80, profilePhotoStream);
byte[] coverPhotoBytes = profilePhotoStream.toByteArray();
ParseFile coverPhotoFile = new ParseFile("profilePicture.png", coverPhotoBytes);
coverPhotoFile.save();
currentUser.put(ParseTables.Users.IMAGE, coverPhotoFile);
}
currentUser.save();
editor.commit();
Log.d(TAG, "Done with everything");
} catch (ParseException e) {
e.printStackTrace();
}
}
示例14: clearFocusAndSubmit
import com.parse.ParseUser; //導入方法依賴的package包/類
private void clearFocusAndSubmit() {
View focussedView = getView().findFocus();
if (focussedView != null) focussedView.clearFocus();
List<String> validationErrors = new ArrayList<>();
//boolean passwordsOK = !StringUtils.isAnyNullOrEmpty(mPassword1) && mPassword1.length()>0;
//if(!passwordsOK) validationErrors.add("Passwords do not match");
final ParseUser parseUser = new ParseUser();
if (mCustomer.password==null || mCustomer.password.length()<CustomerHelper.MIN_PASSWORD_LENGTH)
validationErrors.add(String.format("A valid password is required of at least %d characters", CustomerHelper.MIN_PASSWORD_LENGTH));
else parseUser.setPassword(mCustomer.password);
String email = mCustomer.getEmail();
if(email!=null) {
parseUser.setEmail(email);
parseUser.setUsername(email);
}
parseUser.put("firstName", mCustomer.firstName);
parseUser.put("lastName", mCustomer.lastName);
validationErrors.addAll(CustomerHelper.validate(parseUser));
if(validationErrors.size()>0){
aq.id(R.id.validation).text(StringUtils.stringListToString(validationErrors, "\n", false));
}
else{
requestingCount=1;
onRequestingChanged();
aq.id(R.id.validation).text("");
parseUser.signUpInBackground(new SignUpCallback() {
@Override
public void done(ParseException e) {
requestingCount=0;
onRequestingChanged();
if (e != null) {
new AlertDialog.Builder(getActivity()).setMessage(e.getMessage()).setPositiveButton(R.string.ok, null).show();
} else {
if (ConnectedApp.DEBUG)
Toast.makeText(getActivity(), "Signup success", Toast.LENGTH_SHORT).show();
Session.getInstance().setCustomerHeader(parseUser, mCustomer.password);
// Intent intent = new Intent(getActivity(), PreferencesActivity.class);
// startActivity(intent);
// getActivity().finish();
}
}
});
}
}
示例15: onClick
import com.parse.ParseUser; //導入方法依賴的package包/類
@Override
public void onClick(View v) {
ParseUser.logOut();
final View view = v; //creating an Intent or Toast requires a view casted as 'final'
switch (v.getId()){//identify what item was pressed
case R.id.switchToLoginBtn:
mCallback.onSwitchToLogin();
break;
case R.id.registerBtn:
//start building an alert dialog incase there was an issue with registration credentials
AlertDialog.Builder builder = new AlertDialog.Builder(fragmentContainer.getContext());
builder.setTitle(R.string.app_name);
builder.setPositiveButton(R.string.dialogConfirm, null);
String dialogMsg = "";
//sanitize and validate registration credentials before sending to parse
String EmailStr = emailTxt.getText().toString();
if (Objects.equals(nameTxt.getText().toString(), ""))
dialogMsg = getString(R.string.nameNotValid);
else if (EmailStr.length() <=7 ||
!EmailStr.substring(EmailStr.length() - 7).contains("gcc.edu"))
dialogMsg = getString(R.string.emailNotValid);
else if (!Objects.equals(passTxt.getText().toString(), passConfirmTxt.getText().toString()))
dialogMsg = getString(R.string.passwordsDontMatch);
else if (passTxt.getText().toString().length()<8)
dialogMsg = getString(R.string.passwordTooShort);
else if (!hasDigitsAndLetters(passTxt.getText().toString()))
dialogMsg = getString(R.string.passwordMissingCharacters);
//display dialog if there were any issues
if (dialogMsg != ""){
builder.setMessage(dialogMsg);
AlertDialog errorDialog = builder.create();
errorDialog.show();
break;
}
//create a ParseUser with the provided credentials
ParseUser user = new ParseUser();
user.put("friendlyName", nameTxt.getText().toString());
user.setUsername(emailTxt.getText().toString().toLowerCase());
user.setEmail(emailTxt.getText().toString());
user.setPassword(passTxt.getText().toString());
//dismiss keyboard
InputMethodManager imm = (InputMethodManager)getActivity()
.getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
//show register dialog with progress spinner while Parse executes in the background
signUpDialog.show();
signUpTask = new SignUpTask(user, view,fragmentContainer.getContext());
signUpTask.execute();//attempt to signup in the background
break;
default:
break;
}
}