public void deleteMap(int position) { BeaconMap beaconMap = (BeaconMap) mGridView.getItemAtPosition(position); ParseQuery<Place> parseQueryBeacon = ParseQuery.getQuery("Place"); parseQueryBeacon.whereEqualTo(Constants.COLUMN_PLACE_MAP_ID, beaconMap.getObjectId()); try { ParseQuery<Beacon> beaconParseQuery = ParseQuery.getQuery("Beacon"); beaconParseQuery.whereEqualTo(Constants.COLUMN_BEACON_MAP_ID, beaconMap.getObjectId()); List<Beacon> beaconList = beaconParseQuery.find(); for (Beacon beacon : beaconList) { beacon.deleteInBackground(); } List<Place> placeList = parseQueryBeacon.find(); for (Place place : placeList) { ParseQuery<BeaconPower> beaconPowerParseQuery = ParseQuery.getQuery("BeaconPower"); beaconPowerParseQuery.whereEqualTo( Constants.COLUMN_BEACON_MEASURE_PLACE_ID, place.getObjectId()); List<BeaconPower> beaconPowerList = beaconPowerParseQuery.find(); for (BeaconPower beaconPower : beaconPowerList) { beaconPower.delete(); } place.deleteInBackground(); } } catch (ParseException e) { e.printStackTrace(); } beaconMap.deleteInBackground(); }
static float[] updateGraph() { long timeStep = 1445214540000L; float[] results = new float[numData]; ParseQuery<ParseObject> query = ParseQuery.getQuery("data"); query.whereEqualTo("flag", 1); try { ParseObject flagged = query.getFirst(); timeStep = flagged.getLong("unixTimeStamp"); flagged.put("flag", 0); flagged.saveInBackground(); Log.d("Find Flag", flagged.getObjectId()); } catch (ParseException e) { Log.d("Find Flag", "Error: " + e.getMessage()); } query = ParseQuery.getQuery("data"); query.orderByAscending("unixTimeStamp"); query.whereGreaterThan("unixTimeStamp", timeStep); try { ParseObject nextFlag = query.getFirst(); nextFlag.put("flag", 1); nextFlag.saveInBackground(); Log.d("Set Next Flag", nextFlag.getObjectId() + " is " + nextFlag.getInt("flag")); } catch (ParseException e) { Log.d("Set Next Flag", "Error: " + e.getMessage()); } query = ParseQuery.getQuery("data"); query.orderByDescending("unixTimeStamp"); query.whereLessThan("unixTimeStamp", timeStep); for (int i = 0; i < numData; i++) { try { ParseObject data = query.getFirst(); results[numData - i - 1] = (float) data.getInt("Bg"); query.whereLessThan("unixTimeStamp", data.getLong("unixTimeStamp")); } catch (ParseException e) { Log.d("Fill Results Array", "Failed"); } } /*query.findInBackground(new FindCallback<ParseObject>() { @Override public void done(List<ParseObject> data, ParseException e) { int i = 0; if (e == null) { Log.d("Blood Glucose", "Retrieved " + data.size() + " Blood Glucose Data Points"); for(ParseObject person : data) { results[i] = person.getInt("Bg"); i++; } } else { Log.d("Blood Glucose", "Error: " + e.getMessage()); } } });*/ return results; }
private void startManageContent() { // if you're logged if (app.logged()) { findViewById(R.id.progress).setVisibility(View.VISIBLE); manageNotLoggedText.setVisibility(View.GONE); ParseQuery<ParseObject> query = ParseQuery.getQuery(Consts.PROTEST); query.whereEqualTo(Consts.P_ADMIN, app.getUsername()); query.orderByDescending("createdAt"); query.findInBackground( new FindCallback<ParseObject>() { public void done(List<ParseObject> retrievedProtestList, ParseException e) { if (e == null) { manageProtestArrList = Protest.convertList(retrievedProtestList); manageProtestAdapter = new ProtestsAdapter(con, R.layout.row_protest, manageProtestArrList); manageProtestList.setAdapter(manageProtestAdapter); showHideNoProtestsMsg(retrievedProtestList); } else { Log.v(TAG, "Error: " + e.getMessage()); } findViewById(R.id.progress).setVisibility(View.GONE); } }); } else { notLogged("view protests you manage ", getString(R.string.unregistered_manage)); } }
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; }
public void saveNote() { String titleToSave = titleEditText.getText().toString().trim(); String contentToSave = contentEditText.getText().toString().trim(); if (!contentToSave.isEmpty() || !titleToSave.isEmpty()) { if (note == null) { ParseObject post = new ParseObject("Post"); post.put("title", titleToSave); post.put("content", contentToSave); post.put("author", ParseUser.getCurrentUser()); post.saveInBackground(); callback.onNoteAdded(titleToSave, contentToSave); } else { ParseQuery<ParseObject> query = ParseQuery.getQuery("Post"); final String newTitleToSave = titleToSave; final String newContentToSave = contentToSave; query.getInBackground( note.getId(), new GetCallback<ParseObject>() { @Override public void done(ParseObject parseObject, ParseException e) { if (e == null) { parseObject.put("title", newTitleToSave); parseObject.put("content", newContentToSave); callback.onNoteChanged(new Note(newTitleToSave, newContentToSave), note); parseObject.saveInBackground(); } } }); } } }
private void getCurrentUserId(String phoneNumber) { ParseQuery<ParseObject> query = ParseQuery.getQuery("SimpleUser"); query.whereEqualTo("phone_number", phoneNumber); query.getFirstInBackground( new GetCallback<ParseObject>() { public void done(ParseObject object, ParseException e) { if (e == null) { String userId = object.getObjectId().toString(); String currentUserObjId = userId; SimpleUser.currentUserObjectId = currentUserObjId; // Write the userId in shared pref if the user successfully signed up SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); SharedPreferences.Editor edit = pref.edit(); edit.putString("userId", userId); edit.commit(); Intent returnIntent = new Intent(); setResult(RESULT_OK, returnIntent); finish(); overridePendingTransition(R.anim.stay_in_place, R.anim.exit_to_bottom); } else { Log.d("DEBUG", "Error: " + e.getMessage()); } } }); }
// open history chat from parse private void GetingHistoryChat(final String friend, final String me) { ParseQuery<ParseObject> GetMessageTable = ParseQuery.getQuery("Message"); GetMessageTable.findInBackground( new FindCallback<ParseObject>() { @Override public void done(List<ParseObject> object, ParseException e) { if (e == null) { for (int indx = 0; indx < object.size(); indx++) { // if its my message if (object.get(indx).getString("Receiver").matches(friend) && object.get(indx).getString("Sender").matches(me)) { abp.add( new ChatMessage( side, object.get(indx).getString("txt") + "\n" + object.get(indx).getString("Time"))); } else if (object.get(indx).getString("Receiver").matches(me) && object.get(indx).getString("Sender").matches(friend)) { abp.add( new ChatMessage( !side, object.get(indx).getString("txt") + "\n" + object.get(indx).getString("Time"))); } } } } }); }
// TODO: What to do with strings? leave it of clean it public void getNewPosts(final NewsFeedAdapter adapter) { ParseQuery<ParseObject> query = ParseQuery.getQuery("Post"); query.setLimit(2); query.orderByDescending("createdAt"); query.findInBackground( new FindCallback<ParseObject>() { @Override public void done(List<ParseObject> list, ParseException e) { if (e == null) { ArrayList<News> news = new ArrayList<News>(); for (ParseObject item : list) { News n = new News(); n.setTitle(item.getString("title")); n.setLocation(item.getString("location")); n.setTime(item.getString("time")); n.setText(item.getString("text")); n.setIndicator((ArrayList<String>) item.get("icons")); n.setType(item.getString("type")); n.setDate(item.getDate("date")); n.setAuthor(item.getString("Author")); n.setCreatedAt(item.getCreatedAt()); Log.d("CREATEDAT", item.getCreatedAt().toString()); news.add(n); } mLast = list.get(list.size() - 1).getInt("number"); adapter.addItems(news); } else { e.printStackTrace(); } } }); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_item_display); if (savedInstanceState == null) { Bundle extras = getIntent().getExtras(); if (extras == null) { itemId = null; } else { itemId = extras.getString("itemId"); } } else { itemId = (String) savedInstanceState.getSerializable("itemId"); } if (savedInstanceState == null) { Bundle extras = getIntent().getExtras(); if (extras == null) { imageNum = 0; } else { imageNum = extras.getInt("imageNum"); } } else { imageNum = (int) savedInstanceState.getSerializable("imageNum"); } if (savedInstanceState == null) { Bundle extras = getIntent().getExtras(); if (extras == null) { userId = null; } else { userId = extras.getString("userId"); } } else { userId = (String) savedInstanceState.getSerializable("userId"); } ParseQuery<ParseObject> query = ParseQuery.getQuery("Item"); query.getInBackground( itemId, new GetCallback<ParseObject>() { public void done(ParseObject object, ParseException e) { if (e == null) { if (object.has("itemImage0")) { ImageView displayImage = (ImageView) findViewById(R.id.imageDisplay); ParseFile image = object.getParseFile("itemImage0"); try { byte[] imageData = image.getData(); Bitmap bitmap = BitmapFactory.decodeByteArray(imageData, 0, imageData.length); displayImage.setImageBitmap(bitmap); } catch (ParseException e1) { e1.printStackTrace(); } } } else { } } }); }
public void areFriends1(final ParseUser user) { ParseQuery<ParseObject> query = ParseQuery.getQuery("Friends"); query.whereEqualTo("areFriends", true); query.whereEqualTo("toUser", currentUser.getObjectId() + ""); query.whereEqualTo("fromUser", user.getObjectId() + ""); query.findInBackground( new FindCallback<ParseObject>() { public void done(List<ParseObject> list, ParseException e) { findViewById(R.id.LoadingIcon).setVisibility(View.INVISIBLE); if (e == null && list.size() > 0) { new AlertDialog.Builder(Friends.this) .setTitle("You Are Already Friends!") .setPositiveButton( "OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { add.setEnabled(true); } }) .show(); } else { alreadyRequested(user); } } }); }
public void theyRequested(final ParseUser user) { ParseQuery<ParseObject> query = ParseQuery.getQuery("Friends"); query.whereEqualTo("areFriends", false); query.whereEqualTo("fromUser", user.getObjectId() + ""); query.whereEqualTo("toUser", currentUser.getObjectId() + ""); query.findInBackground( new FindCallback<ParseObject>() { public void done(List<ParseObject> list, ParseException e) { if (e == null && list.size() > 0) { ParseObject relation = list.get(0); relation.put("areFriends", true); relation.saveInBackground(); new AlertDialog.Builder(Friends.this) .setTitle("This User Already Sent You a Request!") .setMessage("You Two Are Now Friends!") .setPositiveButton( "OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { add.setEnabled(true); getRelations(); setNotifications(); } }) .show(); } else { createRelation(user); } } }); }
private void getUserDetailsFromTwitter() { final String name = ParseTwitterUtils.getTwitter().getScreenName().toString(); ParseQuery<ParseUser> query = ParseQuery.getQuery("_User"); query.findInBackground( new FindCallback<ParseUser>() { public void done(List<ParseUser> objects, com.parse.ParseException e) { // userlist.addAll(objects); // ParseUser currentUser = ParseUser.getCurrentUser(); for (int i = 0; i < objects.size() - 1; i++) { // Log.d("demo", "user obj id" + userlist.get(i).getObjectId()); if (objects.get(i).get("name").toString().equals(name)) { Intent intent = new Intent(LoginActivity.this, MainActivity.class); // intent.putExtra(NAME, name); startActivity(intent); flag = 0; } else { flag = 1; } } if (flag == 1) { Intent intent = new Intent(LoginActivity.this, Twitterlogin.class); intent.putExtra(NAME, name); startActivity(intent); } } }); }
public void show1(View v) { String code = tv.getText().toString(); ParseQuery<ParseObject> query = ParseQuery.getQuery("Image"); query.whereEqualTo("Image", code); query.findInBackground( new FindCallback<ParseObject>() { @Override public void done(List<ParseObject> parseObjects, ParseException e) { ParseFile file = (ParseFile) parseObjects.get(0).get("ImageFile"); file.getDataInBackground( new GetDataCallback() { @Override public void done(byte[] bytes, ParseException e) { Bitmap bmp = BitmapFactory.decodeByteArray(bytes, 0, bytes.length); img1.setImageBitmap(bmp); } }); } }); /*DBAdapter1 db = new DBAdapter1(this); String name = db.getbook(code); Uri muri = Uri.parse(name); s = getPath(muri); System.out.println("Image Path : " + s); img1.setImageURI(muri);*/ }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_trainer_details); if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { getWindow().setNavigationBarColor(getResources().getColor(R.color.navigationBarColor)); } setupToolbar(); // Get the trainer object from parse and setup the view trainerId = getIntent().getStringExtra("trainerId"); ParseQuery<Trainer> query = ParseQuery.getQuery("Trainer"); query.whereEqualTo("objectId", trainerId); query.include("favorited_by"); query.findInBackground( new FindCallback<Trainer>() { @Override public void done(List<Trainer> list, com.parse.ParseException e) { Log.d("DEBUG", ((Trainer) list.get(0)).getName()); m_trainer = list.get(0); // Get the gym where the trainer goes to workout getTrainerGym(); } }); }
private void getCurrentUserAndStartChat(String userObjectId) { ParseQuery<SimpleUser> query = ParseQuery.getQuery("SimpleUser"); query.whereEqualTo("objectId", userObjectId); query.getFirstInBackground( new GetCallback<SimpleUser>() { public void done(SimpleUser user, com.parse.ParseException e) { if (e == null) { ChatPerson me = new ChatPerson(); me.name = user.getName(); me.objectId = user.getObjectId(); me.imageUrl = ""; ChatPerson other = new ChatPerson(); other.name = m_trainer.getName(); other.objectId = m_trainer.getObjectId(); other.imageUrl = m_trainer.getProfileImageUrl(); Intent intent = new Intent(getBaseContext(), ChatActivity.class); intent.putExtra("me", me); intent.putExtra("other", other); startActivity(intent); } else { Log.d("DEBUG", "Error: " + e.getMessage()); } } }); }
private void inviteSelectedPlayers( final String gameId, final List<ParseUser> selectedPlayersList) { final ParseQuery<ParseObject> query = ParseQuery.getQuery("gameInfo"); query.getInBackground( gameId, new GetCallback<ParseObject>() { public void done(final ParseObject game, final ParseException e) { if (e == null) { for (final ParseUser invitee : selectedPlayersList) { // see https://parse.com/questions/push-notifications-on-android-to-specific-users ParsePush parsePush = new ParsePush(); ParseQuery<ParseInstallation> pQuery = ParseInstallation.getQuery(); pQuery.whereEqualTo("username", invitee); parsePush.setQuery(pQuery); parsePush.setMessage( "You've been invited to play scavenger hunt: " + game.getString("gameName") + ", by " + ParseUser.getCurrentUser().getString("username")); parsePush.sendInBackground(); } } } }); }
public void getContactInfos(List<String> usernames, final EMValueCallBack<List<User>> callback) { ParseQuery<ParseObject> pQuery = ParseQuery.getQuery(CONFIG_TABLE_NAME); pQuery.whereContainedIn(CONFIG_USERNAME, usernames); pQuery.findInBackground( new FindCallback<ParseObject>() { @Override public void done(List<ParseObject> arg0, ParseException arg1) { if (arg0 != null) { List<User> mList = new ArrayList<User>(); for (ParseObject pObject : arg0) { User user = new User(); ParseFile parseFile = pObject.getParseFile(CONFIG_AVATAR); if (parseFile != null) { user.setAvatar(parseFile.getUrl()); } user.setNick(pObject.getString(CONFIG_NICK)); user.setUsername(pObject.getString(CONFIG_USERNAME)); setUserHearder(user); mList.add(user); } callback.onSuccess(mList); } else { callback.onError(arg1.getCode(), arg1.getMessage()); } } }); }
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 void alreadyRequested(final ParseUser user) { ParseQuery<ParseObject> query = ParseQuery.getQuery("Friends"); query.whereEqualTo("areFriends", false); query.whereEqualTo("toUser", user.getObjectId() + ""); query.whereEqualTo("fromUser", currentUser.getObjectId() + ""); query.findInBackground( new FindCallback<ParseObject>() { public void done(List<ParseObject> list, ParseException e) { if (e == null && list.size() > 0) { new AlertDialog.Builder(Friends.this) .setTitle("You Already Sent a Request to This User!") .setPositiveButton( "OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { add.setEnabled(true); } }) .show(); } else { theyRequested(user); } } }); }
protected void getMarkersFromParse() { ParseQuery<ParseObject> query = ParseQuery.getQuery("Route"); query.findInBackground( new FindCallback<ParseObject>() { @Override public void done(List<ParseObject> routeObjects, com.parse.ParseException e) { if (e == null) { for (ParseObject object : routeObjects) { String id = object.getObjectId().toString(); double longitude = object.getParseGeoPoint("startingPointGeo").getLongitude(); double latitude = object.getParseGeoPoint("startingPointGeo").getLatitude(); String title = object.getString("startingPoint"); String destination = object.getString("destination"); Marker marker = mGoogleMap.addMarker( new MarkerOptions() .position(new LatLng(latitude, longitude)) .title("#id: " + id) .snippet( title + " - " + destination + "\nStart date: " + object.getString("date") + "\nStart time: " + object.getString("time"))); mMarkers.add(marker); } } } }); }
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 onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_choosehackathon); ParseQuery<ParseObject> query = ParseQuery.getQuery("Hackathon"); query.findInBackground( new FindCallback<ParseObject>() { public void done(final List<ParseObject> hackathonList, ParseException e) { if (e == null) { final ArrayList<String> hackathonNames = new ArrayList<String>(); final ListView listChooseHackathon = (ListView) findViewById(R.id.listChooseHackathon); for (ParseObject o : hackathonList) hackathonNames.add(o.getString("name")); ArrayAdapter<String> aa = new ArrayAdapter<String>( context, android.R.layout.simple_list_item_1, hackathonNames); listChooseHackathon.setAdapter(aa); listChooseHackathon.setOnItemClickListener( new AdapterView.OnItemClickListener() { public void onItemClick( AdapterView<?> parentView, View childView, int position, long id) { Intent i = new Intent(context, HackathonInfoActivity.class); Bundle b = new Bundle(); b.putString("hackathon_id", hackathonList.get(position).getObjectId()); b.putString("user_id", getIntent().getExtras().getString("user_id")); i.putExtras(b); startActivity(i); } }); } else alertMessage("Error", "Error retrieving hackathons", true); } }); }
private void updatePostList() { // Create query for objects of type "Post" ParseQuery<ParseObject> query = ParseQuery.getQuery("Post"); // Restrict to cases where the author is the current user. // Note that you should pass in a ParseUser and not the // String representation of that user query.whereEqualTo("author", ParseUser.getCurrentUser()); // Run the query query.findInBackground( new FindCallback<ParseObject>() { @Override public void done(List<ParseObject> postList, ParseException e) { if (e == null) { // If there are results, update the list of posts // and notify the adapter posts.clear(); for (ParseObject post : postList) { posts.add(post.getString("textContent")); } ((ArrayAdapter<String>) getListAdapter()).notifyDataSetChanged(); } else { Log.d("Post retrieval", "Error: " + e.getMessage()); } } }); }
@Override protected String doInBackground(String... params) { // Notify Parse Analytics that the app has been opened ParseAnalytics.trackAppOpenedInBackground(getIntent()); CardDbHelper cardDbHelper = new CardDbHelper(getBaseContext()); SQLiteDatabase db = cardDbHelper.getWritableDatabase(); cardDbHelper.onCreate(db); try { ParseQuery<ParseObject> query = ParseQuery.getQuery("Card"); query.setLimit(1000); query.selectKeys(Arrays.asList("")); List<ParseObject> results = query.find(); Iterator<ParseObject> iterator = results.iterator(); // Writing values to DB ContentValues values = new ContentValues(); while (iterator.hasNext()) { ParseObject next = iterator.next(); values.put("cardId", next.getObjectId().toString()); db.insert(CardDbHelper.TABLE_NAME, "null", values); } } catch (ParseException e) { e.printStackTrace(); } return ""; }
public void moreImageFunction(View view) { ParseQuery<ParseObject> query = ParseQuery.getQuery("Item"); query.getInBackground( itemId, new GetCallback<ParseObject>() { public void done(ParseObject object, ParseException e) { if (e == null) { imageNum = next(imageNum); String item = "itemImage" + imageNum; if (object.has(item)) { ImageView displayImage = (ImageView) findViewById(R.id.imageDisplay); ParseFile image = object.getParseFile(item); try { byte[] imageData = image.getData(); Bitmap bitmap = BitmapFactory.decodeByteArray(imageData, 0, imageData.length); displayImage.setImageBitmap(bitmap); } catch (ParseException e1) { e1.printStackTrace(); } } } else { } } }); }
@Override protected void onResume() { super.onResume(); if (!onResumeHasRun) { onResumeHasRun = true; return; } movieList = new ArrayList<String>(); noItemsTV.setVisibility(View.GONE); ParseUser currentUser = ParseUser.getCurrentUser(); if (currentUser != null) { ParseQuery<ParseObject> query = ParseQuery.getQuery("itemInfo"); query.whereEqualTo("user", currentUser); query.findInBackground( new FindCallback<ParseObject>() { @Override public void done(List<ParseObject> movObjs, ParseException arg1) { // TODO Auto-generated method stub if (arg1 == null) { for (ParseObject object : movObjs) { movieList.add(object.get("title").toString()); } setAdapter(); } else { Log.d("Error", "Error: " + arg1.getMessage()); } } }); } }
private void displayInfo() { // get the info that was passed in from EventVoteActivity String eventId = getIntent().getExtras().getString("eventId"); position = getIntent().getExtras().getInt("position"); // find the Event in Parse to grab info from ParseQuery<ParseObject> query = ParseQuery.getQuery("Event"); query.whereEqualTo("objectId", eventId); query.findInBackground( new FindCallback<ParseObject>() { @Override public void done(List<ParseObject> list, ParseException e) { if (e == null) { // set the text on the page to the information for that restaurant // that is stored in Parse ParseObject obj = list.get(0); restaurantName.setText((String) obj.getList("restaurants").get(position)); rating.setText((String) obj.getList("ratings").get(position)); type.setText((String) obj.getList("typeOfFood").get(position)); address.setText((String) obj.getList("addresses").get(position)); phone.setText((String) obj.getList("phoneNumbers").get(position)); } } }); }
public void syncWithParse() { ParseQuery<ParseObject> query = ParseQuery.getQuery(ParseConstants.CLASS_SAVED_WORD); query.whereEqualTo(ParseConstants.SAVED_WORD_USER, ParseUser.getCurrentUser()); query.findInBackground( new FindCallback<ParseObject>() { @Override public void done(List<ParseObject> words, ParseException e) { if (e == null) { // delete current data in Parse for (ParseObject word : words) { word.deleteInBackground(); } // save data in local database to Parse ParseQuery<ParseObject> query = ParseQuery.getQuery(ParseConstants.CLASS_SAVED_WORD); query.whereEqualTo(ParseConstants.SAVED_WORD_USER, ParseUser.getCurrentUser()); query.fromLocalDatastore(); query.findInBackground( new FindCallback<ParseObject>() { @Override public void done(List<ParseObject> words, ParseException e) { if (e == null) { // save each word to Parse for (ParseObject word : words) { word.saveInBackground(); } } } }); } } }); }
/** This function downloads the Splash Image from the Parse Table 'Splash' */ public void downloadSplashImage() { Log.e("downloadSplashImage", "downloadSplashImage"); dialog1.setMessage("Downloading Splash Image..."); ParseQuery<ParseObject> query = ParseQuery.getQuery("Splash"); query.whereEqualTo("username", Login.USERNAME); query.findInBackground( new FindCallback<ParseObject>() { public void done(List<ParseObject> objects, ParseException e) { if (e == null) { ParseFile myFile = objects.get(0).getParseFile("image"); myFile.getDataInBackground( new GetDataCallback() { public void done(byte[] data, ParseException e) { if (e == null) { // user the function writeFile() to create the file in the Internal Memory // the file name will be like someusername_splash.jpg writeFile(data, Login.USERNAME + "_splash.jpg"); // once the splash image is downloaded, we need to download the images for // the listview. downloadImages(); } else { Log.e("Something went wrong", "Something went wrong"); } } }); } else { Log.e("PARSE", "Error: " + e.getMessage()); } } }); }
public void asyncGetUserInfo(final String username, final EMValueCallBack<User> callback) { ParseQuery<ParseObject> pQuery = ParseQuery.getQuery(CONFIG_TABLE_NAME); pQuery.whereEqualTo(CONFIG_USERNAME, username); pQuery.getFirstInBackground( new GetCallback<ParseObject>() { @Override public void done(ParseObject pUser, ParseException e) { if (pUser != null) { String nick = pUser.getString(CONFIG_NICK); ParseFile pFile = pUser.getParseFile(CONFIG_AVATAR); if (callback != null) { User user = UserUtils.getUserInfo(username); if (user != null) { user.setNick(nick); if (pFile != null && pFile.getUrl() != null) { user.setAvatar(pFile.getUrl()); } } callback.onSuccess(user); } } else { if (callback != null) { callback.onError(e.getCode(), e.getMessage()); } } } }); }