public boolean updateParseNickName(final String nickname) { String username = EMChatManager.getInstance().getCurrentUser(); ParseQuery<ParseObject> pQuery = ParseQuery.getQuery(CONFIG_TABLE_NAME); pQuery.whereEqualTo(CONFIG_USERNAME, username); ParseObject pUser = null; try { pUser = pQuery.getFirst(); if (pUser == null) { return false; } pUser.put(CONFIG_NICK, nickname); pUser.save(); return true; } catch (ParseException e) { if (e.getCode() == ParseException.OBJECT_NOT_FOUND) { pUser = new ParseObject(CONFIG_TABLE_NAME); pUser.put(CONFIG_USERNAME, username); pUser.put(CONFIG_NICK, nickname); try { pUser.save(); return true; } catch (ParseException e1) { e1.printStackTrace(); EMLog.e(TAG, "parse error " + e1.getMessage()); } } e.printStackTrace(); EMLog.e(TAG, "parse error " + e.getMessage()); } return false; }
public String uploadParseAvatar(byte[] data) { String username = EMChatManager.getInstance().getCurrentUser(); ParseQuery<ParseObject> pQuery = ParseQuery.getQuery(CONFIG_TABLE_NAME); pQuery.whereEqualTo(CONFIG_USERNAME, username); ParseObject pUser = null; try { pUser = pQuery.getFirst(); if (pUser == null) { pUser = new ParseObject(CONFIG_TABLE_NAME); pUser.put(CONFIG_USERNAME, username); } ParseFile pFile = new ParseFile(data); pUser.put(CONFIG_AVATAR, pFile); pUser.save(); return pFile.getUrl(); } catch (ParseException e) { if (e.getCode() == ParseException.OBJECT_NOT_FOUND) { try { pUser = new ParseObject(CONFIG_TABLE_NAME); pUser.put(CONFIG_USERNAME, username); ParseFile pFile = new ParseFile(data); pUser.put(CONFIG_AVATAR, pFile); pUser.save(); return pFile.getUrl(); } catch (ParseException e1) { e1.printStackTrace(); EMLog.e(TAG, "parse error " + e1.getMessage()); } } else { e.printStackTrace(); EMLog.e(TAG, "parse error " + e.getMessage()); } } return null; }
private void activePatientData() { ParseQuery<ParseObject> query = ParseQuery.getQuery("PatientDetails"); query.whereEqualTo("patientId", patientIdRemove); try { ParseObject object = query.getFirst(); object.put("status", "Active"); object.save(); } catch (ParseException e2) { // TODO Auto-generated catch block e2.printStackTrace(); } /* ParseQuery<ParseObject> query3 = ParseQuery.getQuery("_User"); query3.whereEqualTo("userId", patientIdRemove); try { ParseObject object = query3.getFirst(); object.put("status", "Active"); object.save(); }catch (ParseException e2) { // TODO Auto-generated catch block e2.printStackTrace(); }*/ Toast.makeText(SearchPatientByAdmin.this, "Patient Active", Toast.LENGTH_SHORT).show(); }
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == REQUEST_IMAGE_CAPTURE && resultCode == RESULT_OK) { Bundle extras = data.getExtras(); Bitmap imageBitmap = (Bitmap) extras.get("data"); mImageView = (ImageView) findViewById(R.id.imgView); // Saving in Parse server ByteArrayOutputStream stream = new ByteArrayOutputStream(); imageBitmap.compress(Bitmap.CompressFormat.PNG, 100, stream); byte[] dataTostore = stream.toByteArray(); final ParseFile imgFile = new ParseFile("img.png", dataTostore); imgFile.saveInBackground(); GalleryObj tempPicObj = new GalleryObj(); ParseObject obj = new ParseObject("Gallery"); obj.put("pic", imgFile); obj.put("Apartment", ParseUser.getCurrentUser().getString("Apartment")); try { obj.save(); tempPicObj.id = obj.getObjectId(); tempPicObj.pic = imageBitmap; STgallery.getInstance().add(tempPicObj); } catch (ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } adapter.notifyDataSetChanged(); } }
// Uploads data to parse server as student object private void addToParse() { ParseObject studentObj = new ParseObject("Student"); studentObj.put("name", name); studentObj.put("facebookID", facebookID); studentObj.addAll("courses", classes); studentObj.addAll("friendsList", friendsList); try { studentObj.save(); } catch (ParseException a) { a.printStackTrace(); } }
public static void savePictureToPostSync(ParseObject mPost, Bitmap picture) { ByteArrayOutputStream stream = new ByteArrayOutputStream(); picture.compress(Bitmap.CompressFormat.JPEG, 100, stream); byte[] bytearray = stream.toByteArray(); ParseFile questionPicture = new ParseFile(mPost.getObjectId() + "_picture.jpg", bytearray); try { questionPicture.save(); mPost.put(Common.OBJECT_POST_PICTURE, questionPicture); mPost.save(); } catch (Exception e) { e.printStackTrace(); } }
public void inactivePatientData() { ParseQuery<ParseObject> query = ParseQuery.getQuery("PatientDetails"); query.whereEqualTo("patientId", patientIdRemove); try { ParseObject object = query.getFirst(); object.put("status", "Inactive"); object.save(); } catch (ParseException e2) { // TODO Auto-generated catch block e2.printStackTrace(); } /* ParseQuery<ParseObject> query1 = ParseQuery.getQuery("AppointmentDetails"); query1.whereEqualTo("patientId", patientIdRemove); try { List<ParseObject> objects = query1.find(); for (ParseObject p : objects) { p.delete(); } }catch (ParseException e2) { // TODO Auto-generated catch block e2.printStackTrace(); }*/ /*ParseQuery<ParseObject> query2 = ParseQuery.getQuery("MedicalRecords"); query2.whereEqualTo("patientId", patientIdRemove); try { List<ParseObject> objects = query2.find(); for (ParseObject p : objects) { p.delete(); } }catch (ParseException e2) { // TODO Auto-generated catch block e2.printStackTrace(); }*/ /* ParseQuery<ParseObject> query3 = ParseQuery.getQuery("_User"); query3.whereEqualTo("userId", patientIdRemove); try { ParseObject object = query3.getFirst(); object.put("status", "Inactive"); object.save(); }catch (ParseException e2) { // TODO Auto-generated catch block e2.printStackTrace(); } */ Toast.makeText(SearchPatientByAdmin.this, "Patient Inactive", Toast.LENGTH_SHORT).show(); }
@Override protected Void doInBackground(Clicker... clickers) { b = clickers[0]; try { ImgurApi imgur = new ImgurApi(context); String s = Long.toString(System.currentTimeMillis()); b.objectId = s; String res = imgur.uploadImageinForeground(b.objectId, b.img_url); if (!res.equals("error")) { b.img_url = res; ParseObject obj = Clicker.getParseObjfromClicker(b); // Save to parse obj.save(); } else e = new Exception("Oops! Could not upload image. Please try again."); } catch (Exception e1) { e1.printStackTrace(); e = e1; } return null; }
@Override protected Void doInBackground(Book... books) { b = books[0]; saveBookLocaly(b); try { ImgurApi imgur = new ImgurApi(context); String res = imgur.uploadImageinForeground(b.isbn, b.img_url); if (!res.equals("error")) { b.img_url = res; ParseObject obj = Book.getParseObjfromBook(b); // Save to parse obj.save(); } else { e = new Exception("Oops! Could not upload image. Please try again."); return null; } } catch (Exception e1) { e = e1; e1.printStackTrace(); } return null; }