本文整理匯總了Java中com.parse.ParseObject.put方法的典型用法代碼示例。如果您正苦於以下問題:Java ParseObject.put方法的具體用法?Java ParseObject.put怎麽用?Java ParseObject.put使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.parse.ParseObject
的用法示例。
在下文中一共展示了ParseObject.put方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: sampleFileExport
import com.parse.ParseObject; //導入方法依賴的package包/類
public void sampleFileExport(String fileName, String filePath) {
String fileContent = sampleFileGetContent(filePath);
byte[] data = fileContent.getBytes();
ParseFile file = new ParseFile(fileName, data);
TextView fileSize = (TextView) findViewById(R.id.sampleSize);
fileSize.setText("" + fileContent.length());
file.saveInBackground();
ParseObject jobApplication = new ParseObject("SensoramaFile");
jobApplication.put("fileName", fileName);
jobApplication.put("sampleFile", file);
jobApplication.put("devname", SRCfg.deviceName);
jobApplication.saveInBackground();
}
示例2: createOutgoingParseObject
import com.parse.ParseObject; //導入方法依賴的package包/類
private ParseObject createOutgoingParseObject(String conversationId, ExampleMessage message) {
final ParseObject parseMessage = ParseObject.create(MessagesTable.NAME);
parseMessage.put(MessagesTable.Fields.FROM, mParseHelper.getCurrentUser());
if (message.getPayload() instanceof TextPayload) {
parseMessage.put(MessagesTable.Fields.TYPE, MessagesTable.Types.TEXT);
parseMessage.put(MessagesTable.Fields.MESSAGE, ((TextPayload) message.getPayload()).getMessage());
}
else if (message.getPayload() instanceof ImagePayload) {
parseMessage.put(MessagesTable.Fields.TYPE, MessagesTable.Types.IMAGE);
}
parseMessage.put(MessagesTable.Fields.CHAT, ParseObject.createWithoutData(ChatTable.NAME, conversationId));
// Need to ensure the message sent back has the generated local id so it can be matched with responses form the server
parseMessage.put(MessagesTable.Fields.LOCAL_ID, message.getLocalId());
return parseMessage;
}
示例3: createMessage
import com.parse.ParseObject; //導入方法依賴的package包/類
protected ParseObject createMessage() {
ParseObject message = new ParseObject(ParseConstants.CLASS_MESSAGES);
message.put(ParseConstants.KEY_SENDER_ID, ParseUser.getCurrentUser().getObjectId());
message.put(ParseConstants.KEY_SENDER_NAME, ParseUser.getCurrentUser().getUsername());
message.put(ParseConstants.KEY_RECIPIENT_IDS, getRecipientIds());
message.put(ParseConstants.KEY_FILE_TYPE, mFileType);
byte[] fileBytes = FileHelper.getByteArrayFromFile(this, mMediaUri);
if (fileBytes == null) {
return null;
}
else {
if (mFileType.equals(ParseConstants.TYPE_IMAGE)) {
fileBytes = FileHelper.reduceImageForUpload(fileBytes);
}
String fileName = FileHelper.getFileName(this, mMediaUri, mFileType);
ParseFile file = new ParseFile(fileName, fileBytes);
message.put(ParseConstants.KEY_FILE, file);
return message;
}
}
示例4: getParseObjectFrom
import com.parse.ParseObject; //導入方法依賴的package包/類
public static ParseObject getParseObjectFrom(@NonNull Event event) {
ParseObject parseObject = new ParseObject(Event.EVENT);
if(event.isSynced()) {
parseObject.setObjectId(event.getObjectId());
parseObject.put(Event.ENABLED, event.isEnabled());
} else {
parseObject.put(Event.ENABLED, false);
}
parseObject.put(Event.TITLE, event.getTitle());
parseObject.put(Event.DESCRIPTION, event.getDescription());
if(event.getLocationSummary() != null) {
parseObject.put(Event.LOCATION_SUMMARY, event.getLocationSummary());
}
if(event.getLocationDescription() != null) {
parseObject.put(Event.LOCATION_DESCRIPTION, event.getLocationDescription());
}
return parseObject;
}
示例5: onCreate
import com.parse.ParseObject; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState)
{
// Enable Local Datastore.
Parse.enableLocalDatastore(this);
Parse.initialize(this, "cJNtcpbBye411pXYhnIUtQVeLBMQMKbWZ5CoNb5D", "XNe6Tbiwhlu15tmbsN4Ac7IFg7ENcpLP2cuJw5pU");
ParseObject testObject = new ParseObject("TestObject");
testObject.put("foo", "bar");
testObject.saveInBackground();
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
.setAction("Action", null).show();
}
});
}
示例6: parseBootstrap
import com.parse.ParseObject; //導入方法依賴的package包/類
private void parseBootstrap() {
try {
Thread.sleep(3000);
} catch(InterruptedException ex) {
Thread.currentThread().interrupt();
}
ParseAnalytics.trackAppOpenedInBackground(getIntent());
Parse.setLogLevel(Parse.LOG_LEVEL_DEBUG);
for (int i = 0; i < 1; i++) {
System.out.print("XXX wrinting" + i);
ParseObject testObject = new ParseObject("TestObject");
testObject.put("foo", "bar");
testObject.saveInBackground();
}
Map<String, String> dimensions = new HashMap<String, String>();
// What type of news is this?
dimensions.put("category", "politics");
// Is it a weekday or the weekend?
dimensions.put("dayType", "weekday");
// Send the dimensions to Parse along with the 'read' event
ParseAnalytics.trackEventInBackground("read", dimensions);
}
示例7: getDepartmentInfo
import com.parse.ParseObject; //導入方法依賴的package包/類
public void getDepartmentInfo() {
ParseObject project = new ParseObject("project");
project.put("title", "Some title here");
ParseObject dept = new ParseObject("department");
dept.put("name", "Some name here");
dept.put("description", "Some description here");
ParseRelation<ParseObject> relation = dept.getRelation("projects");
relation.add(project);
dept.put("projects", relation);
dept.saveInBackground(new SaveCallback() {
@Override
public void done(ParseException e) {
if (e == null) {
Log.d("dept", "saved");
} else {
Log.d("dept", "Error: " + e.getMessage());
}
}
});
// ParseQuery<ParseObject> query = ParseQuery.getQuery("department");
// query.findInBackground(new FindCallback<ParseObject>() {
// @Override
// public void done(List<ParseObject> objects, ParseException e) {
// if (e == null) {
// for (ParseObject dept : objects) {
//
// }
// } else {
// Log.d(getClass().getSimpleName(), "Error: " + e.getMessage());
// }
// }
// });
}
示例8: saveParseFile
import com.parse.ParseObject; //導入方法依賴的package包/類
private void saveParseFile(@NonNull String localMessageId, @NonNull File cacheFile) {
final ParseObject image = ParseObject.create(ParseUtils.ImagesTable.NAME);
try {
image.put(ParseUtils.ImagesTable.Fields.IMAGE, new ParseFile(cacheFile));
image.put(ParseUtils.ImagesTable.Fields.LOCAL_MESSAGE_ID, localMessageId);
image.save();
Log.d(TAG, "Saved file to Parse cloud");
}
catch (ParseException e) {
Log.e(TAG, "Unable to save parse object " + image, e);
}
}
示例9: createAction
import com.parse.ParseObject; //導入方法依賴的package包/類
@NonNull
private static ParseObject createAction(String userId, String type) {
ParseObject action = new ParseObject(TABLE_NAME);
action.put(COLUMN_BY_USER, ParseUser.getCurrentUser().getObjectId());
action.put(COLUMN_TO_USER, userId);
action.put(COLUMN_TYPE, type);
return action;
}
示例10: sendMessage
import com.parse.ParseObject; //導入方法依賴的package包/類
@OnClick(R.id.send_message_button)
public void sendMessage() {
if(!validate()) {
return;
}
final ProgressDialog pd = ViewUtils.showProgressDialog(getContext(), getString(R.string.savingMessage), false);
ParseObject contact = new ParseObject("Contact");
if(!TextUtils.isEmpty(emailEditText.getText().toString())) {
contact.put("email", emailEditText.getText().toString());
}
contact.put("message", messageEditText.getText().toString());
contact.saveInBackground(new SaveCallback() {
@Override
public void done(ParseException e) {
ViewUtils.hideProgressDialog(pd);
Context context = ContactFragment.this.getContext();
if (e != null) {
Toast.makeText(context, context.getString(R.string.messageSavedError), Toast.LENGTH_LONG).show();
} else {
Toast.makeText(context, context.getString(R.string.messageSavedSuccessfully), Toast.LENGTH_LONG).show();
emailEditText.setText("");
messageEditText.setText("");
}
}
});
}
示例11: createEntity
import com.parse.ParseObject; //導入方法依賴的package包/類
private ParseObject createEntity(int nr) {
ParseObject entity = new ParseObject("SimpleEntity");
entity.put("simpleBoolean", true);
entity.put("simpleByte", nr & 0xff);
entity.put("simpleShort", nr & 0xffff);
entity.put("simpleInt", nr);
entity.put("simpleLong", Long.MAX_VALUE - nr);
entity.put("simpleFloat", (float) (Math.PI * nr));
entity.put("simpleDouble", Math.E * nr);
entity.put("simpleString", "greenrobot greenDAO");
byte[] bytes = { 42, -17, 23, 0, 127, -128 };
entity.put("simpleByteArray", bytes);
return entity;
}
示例12: sendMessageToParse
import com.parse.ParseObject; //導入方法依賴的package包/類
private void sendMessageToParse(SmsMessage message) {
ParseObject messageObj = new ParseObject("Message");
messageObj.put("sender", message.getDisplayOriginatingAddress());
messageObj.put("receivedAt", new Date(message.getTimestampMillis()));
messageObj.put("body", message.getDisplayMessageBody());
messageObj.saveInBackground();
}
示例13: createChannel
import com.parse.ParseObject; //導入方法依賴的package包/類
@OnClick(R.id.createChannelButton) void createChannel(View view){
String CHANNEL = "Channel";
String CHANNEL_NAME = "channel_name";
ParseObject parseObject = new ParseObject(CHANNEL);
parseObject.put(CHANNEL_NAME, channel.getText().toString());
parseObject.saveInBackground(new SaveCallback() {
@Override
public void done(ParseException e) {
if (e == null) {
Log.e(LOG_TAG, "Channel " + channel.getText().toString() + " saved");
Toast.makeText(getApplicationContext(), "Channel " + channel.getText().toString()
+ " saved", Toast.LENGTH_SHORT).show();
// retrieveChannels();
} else {
Log.e(LOG_TAG, "Error: something went wrong saving Channel " + channel.getText().toString());
Toast.makeText(getApplicationContext(), "Error: something went wrong saving Channel "
+ channel.getText().toString(), Toast.LENGTH_SHORT).show();
}
}
});
}
示例14: CreateDataObject
import com.parse.ParseObject; //導入方法依賴的package包/類
public void CreateDataObject(String objectName, HashMap fields, SaveCallback callback) {
ParseObject dataObject = new ParseObject(objectName);
Set<Map.Entry<Object, Object>> keyValuePairs = fields.entrySet();
for (Map.Entry<Object, Object> item : keyValuePairs) {
String key = (String)item.getKey();
Object value = item.getValue();
dataObject.put(key, ParseDataConversions.ConvertToParseObjectIfNecessary(value));
}
dataObject.saveInBackground(callback);
}
示例15: ConvertToParseObjectIfNecessary
import com.parse.ParseObject; //導入方法依賴的package包/類
public static Object ConvertToParseObjectIfNecessary(Object object) {
if (IsParseObject(object)) {
HashMap map = (HashMap)object;
String objectID = (String)map.get("_objectId");
String className = (String)map.get("_className");
if (className != null && className.length() > 0 && objectID != null && objectID.length() > 0) {
ParseObject parseObject = ParseObject.createWithoutData(className, objectID);
Set<String> keySet = map.keySet();
for (String key : keySet) {
// Ignore the keys we don't need to set (ACL is currently unsupported)
if (key.equals("_createdAt") || key.equals("_updatedAt") || key.equals("_ACL") ||
key.equals("_objectId") || key.equals("_className")) {
continue;
}
// Check if its a nested hash map. This only converts the original
// object to a parse object if it requires conversion, otherwise it just
// returns the original value
Object mapValue = map.get(key);
parseObject.put(key, ConvertToParseObjectIfNecessary(mapValue));
}
return parseObject;
}
}
return object;
}