private void localQuery(){ ParseQuery<Kid> lQuery = ParseQuery.getQuery(Kid.class).fromLocalDatastore(); lQuery.orderByAscending("createdAt"); lQuery.findInBackground(new FindCallback<Kid>() { @Override public void done(List<Kid> list, ParseException e) { if (e == null) { kidArrayList.clear(); kidArrayList.addAll(list); fillHashMap(); adapter = new AddAttendanceAdapter(AddAttendance.this,kidArrayList,activityMap); listView.setAdapter(adapter); listView.invalidate(); } } }); }
private void localQuery(){ ParseQuery<Kid> query = ParseQuery.getQuery(Kid.class).fromLocalDatastore(); query.orderByAscending("createdAt"); query.findInBackground(new FindCallback<Kid>() { @Override public void done(List<Kid> list, @Nullable ParseException e) { if (e == null && list.size()!=0) { kidArrayList.clear(); kidArrayList.addAll(list); applyAttendanceToKids(); adapter.notifyDataSetChanged(); listView.invalidate(); } } }); }
private void serverQuery() { ParseQuery<Kid> query = ParseQuery.getQuery(Kid.class); query.orderByAscending("createdAt"); query.findInBackground(new FindCallback<Kid>() { @Override public void done(List<Kid> list, @Nullable ParseException e) { if (e == null){ kidArrayList.clear(); kidArrayList.addAll(list); Kid.pinAllInBackground(kidArrayList); applyAttendanceToKids(); adapter.notifyDataSetChanged(); listView.invalidate(); }else if(checkConnection()){ toaster("Error getting data from Server\nWorking offline!","l"); } } }); }
@Override public List<Anime> getAnimeListByUrl(String url) { ArrayList<Anime> animeList = new ArrayList<>(); ParseQuery<AnimeRecord> query = AnimeRecord.getQuery(); try { List<AnimeRecord> animeRecords = query.whereContains("url", url).find(); for (AnimeRecord record : animeRecords) { Anime anime = AnimeRecord.toAnime(record); if (anime != null) animeList.add(anime); } } catch (ParseException e) { WriteLog.appendLogException(TAG, "getAnimeListByUrl(" + url + ") failed", e); } return animeList; }
@Override public List<Anime> getAnimeListByTitle(String title) { ArrayList<Anime> animeList = new ArrayList<>(); ParseQuery<AnimeRecord> query = AnimeRecord.getQuery(); try { List<AnimeRecord> animeRecords = query.whereContains("title", title).find(); for (AnimeRecord record : animeRecords) { Anime anime = AnimeRecord.toAnime(record); if (anime != null) animeList.add(anime); } } catch (ParseException e) { WriteLog.appendLogException(TAG, "getAnimeListByTitle(" + title + ") failed", e); } return animeList; }
public void getContactInfos(List<String> usernames, final EMValueCallBack<List<EaseUser>> 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<EaseUser> mList = new ArrayList<EaseUser>(); for (ParseObject pObject : arg0) { EaseUser user = new EaseUser(pObject.getString(CONFIG_USERNAME)); ParseFile parseFile = pObject.getParseFile(CONFIG_AVATAR); if (parseFile != null) { user.setAvatar(parseFile.getUrl()); } user.setNick(pObject.getString(CONFIG_NICK)); EaseCommonUtils.setUserInitialLetter(user); mList.add(user); } callback.onSuccess(mList); } else { callback.onError(arg1.getCode(), arg1.getMessage()); } } }); }
public static void retreiveprofile(String username , final Context context) { ParseQuery<ParseObject> query= ParseQuery.getQuery("Profile"); query.whereEqualTo("user",username); query.getFirstInBackground(new GetCallback<ParseObject>() { @Override public void done(ParseObject parseObject, ParseException e) { if(parseObject!=null && e==null) { ParseFile file = (ParseFile) parseObject.get("image"); String url = "http://wwww.webianks.com"; if (file != null) { url = file.getUrl().toString(); } MainActivity.retriveProfileCallback(context, url); }else{ //canntretrivee file } } }); }
public static void retreivetimelineprofile(String username , final Context context) { ParseQuery<ParseObject> query= ParseQuery.getQuery("Profile"); query.whereEqualTo("user",username); query.getFirstInBackground(new GetCallback<ParseObject>() { @Override public void done(ParseObject parseObject, ParseException e) { if(parseObject!=null && e==null) { ParseFile file = (ParseFile) parseObject.get("image"); String url = "http://wwww.webianks.com"; if (file != null) { url = file.getUrl().toString(); } Profile.retriveTimelineProfileCallback(context, url); }else{ //canntretrivee file } } }); }
public void categorySpinnerSetup() { ParseQueryAdapter.QueryFactory<ParseObject> factory = new ParseQueryAdapter.QueryFactory<ParseObject>() { public ParseQuery create() { ParseQuery query = new ParseQuery("Category"); return query; } }; categoryAdapter = new ParseQueryAdapter<ParseObject>(this, factory); categoryAdapter.setTextKey("name"); categorySpinner.setAdapter(categoryAdapter); categorySpinner.setSelection(1); categorySpinner .setOnItemSelectedListener(new CategorySpinnerListener()); }
private void loadParseData(String Id){ ParseQuery<ParseObject> query = ParseQuery.getQuery(EventTable); query.whereEqualTo("PhotoAlbumId", Id); query.findInBackground(new FindCallback<ParseObject>() { @Override public void done(List<ParseObject> productParseList, com.parse.ParseException e) { if (e == null) { if(productParseList.size() > 0){ eventList.addAll(productParseList); eventAdapter = new PhotosAdapter(mContext, eventList); gridView.setAdapter(eventAdapter); }else{ Toast.makeText(mContext,"Danh sách trống", Toast.LENGTH_SHORT).show(); } } else { e.printStackTrace(); LoggerFactory.e("loadParseData", "Error: " + e.getMessage()); } } }); }
private void loadParseData(){ ParseQuery<ParseObject> query = ParseQuery.getQuery(tableName); query.findInBackground(new FindCallback<ParseObject>() { @Override public void done(List<ParseObject> productParseList, com.parse.ParseException e) { if (e == null) { if(productParseList.size() > 0){ eventList.addAll(productParseList); eventAdapter = new VideoAdapter(mContext, eventList); gridView.setAdapter(eventAdapter); }else{ Toast.makeText(mContext,"Danh sách trống", Toast.LENGTH_SHORT).show(); } } else { e.printStackTrace(); LoggerFactory.e("loadParseData", "Error: " + e.getMessage()); } } }); }
private void verifyOrganization(){ final String enteredText = orgName.getText().toString().trim(); final RefreshingDialog rd = new RefreshingDialog(this); rd.createRefreshingDialog(); ParseQuery<Organization> query = ParseQuery.getQuery(Organization.class); query.whereEqualTo("name", enteredText); query.findInBackground(new FindCallback<Organization>() { @Override public void done(List<Organization> objects, ParseException e) { if(objects.isEmpty()){//new group createGroupAlert(enteredText); rd.stop(); }else{ joinGroupAlert(objects.get(0)); rd.stop(); } } }); }
private void loadData() { ParseQuery<UserInfo> query = ParseQuery.getQuery(UserInfo.class); query.orderByDescending("score").setLimit(10); query.findInBackground(new FindCallback<UserInfo>() { @Override public void done(List<UserInfo> objects, ParseException e) { list.addAll(objects); runOnUiThread(new Runnable() { @Override public void run() { adapter.notifyDataSetChanged(); } }); } }); }
/** * Request a single message in a conversation to be updated. */ private void updateMessage(@NonNull String conversationId, @NonNull String messageId) { ParseQuery<ParseObject> query = new ParseQuery<>(MessagesTable.NAME); query.setCachePolicy(ParseQuery.CachePolicy.NETWORK_ONLY); query.include(MessagesTable.Fields.IMAGE); Log.d(TAG, "Updating message: " + messageId); mParseHelper.get(query, messageId) .map(in -> ParseUtils.from(in, mParseHelper)) .toList() .subscribe(messages -> { for (ExampleMessage message : messages) { mUpdatePublisher.onNext(new Update<>(conversationId, Update.Action.UPDATED, null, message)); } }); }
@Test public void getConversation() { // Setup final String userId = "userId"; mockCurrentUser(userId); final List<ParseObject> subscriptions = ModelTestHelper.createSubscriptions(10); final String chatId = "chatId"; when(mMockParseHelper.find(Mockito.<ParseQuery<ParseObject>>any())).thenReturn(Observable.just(subscriptions)); // Execute final TestSubscriber<ExampleConversation> testSubscriber = executeTarget(mTarget.get(new GetConversationQuery(chatId))); // Assert testSubscriber.assertCompleted(); verify(mMockParseHelper).find(mParseQueryArgumentCaptor.capture()); final ParseQuery<ParseObject> parseQuery = mParseQueryArgumentCaptor.getValue(); assertThat(testSubscriber.getOnNextEvents().size(), is(10)); assertThat(parseQuery.getClassName(), is(ChatSubscriptionTable.NAME)); }
public void localTeamList() { // Query backend ParseQuery<ParseObject> query = ParseQuery.getQuery("T" + teamNumber); query.fromLocalDatastore().findInBackground(new FindCallback<ParseObject>() { @Override public void done(List<ParseObject> list, ParseException e) { // No exception, query successful if (e == null) { teams.clear(); Collections.reverse(list); for (ParseObject object : list) { if (object.getString("team").equals("")) continue; Team team = new Team(object.getString("team"), object.getString("region"), object.getString("school"), object.getString("teamName"), object.getObjectId()); teams.add(team); } } adapter.notifyDataSetChanged(); refresh.setRefreshing(false); } }); }
public void retrieveChannels(){ ParseQuery query = new ParseQuery("Channel"); query.findInBackground(new FindCallback<ParseObject>() { public void done(List<ParseObject> channels, ParseException e) { if (e == null) { Log.e(LOG_TAG, "Retrieved channels. Size: "+channels.size()); if (channels.size() > 0) { mRetrievedChannels = (List) channels; } } else { Log.e(LOG_TAG, "Error: " + e.getMessage()); } } }); }
public void addCommentTask(){ ParseQuery<ParseObject> query = ParseQuery.getQuery("BullshITBankDB"); query.whereEqualTo("phone", Phone); query.getFirstInBackground(new GetCallback<ParseObject>() { @Override public void done(ParseObject parseObject, ParseException e) { Log.d("TAG","Done Loading Detail!"); String NewComment = AddComment.getText().toString(); List<String> CommentsList = parseObject.getList("comments"); if(CommentsList==null){ CommentsList = new ArrayList<String>(); } CommentsList.add(NewComment+"["+GUID+"]"); parseObject.put("comments",CommentsList); parseObject.saveInBackground(); loadDetail(); } }); }
public void addCommentTask(String Number, final String Comment, final String GUID){ ParseQuery<ParseObject> query = ParseQuery.getQuery("BullshITBankDB"); query.whereEqualTo("phone", Number); query.getFirstInBackground(new GetCallback<ParseObject>() { @Override public void done(ParseObject parseObject, ParseException e) { Log.d("TAG", "Done Loading Detail!"); List<String> CommentsList = parseObject.getList("comments"); if(CommentsList==null){ CommentsList = new ArrayList<String>(); } CommentsList.add(Comment+"["+GUID+"]"); parseObject.put("comments",CommentsList); parseObject.saveInBackground(); } }); }
private void check() { ParseQuery<ParseObject> query = ParseQuery.getQuery("Exsmple"); query.whereEqualTo("name", etNick.getText().toString()); query.findInBackground(new FindCallback<ParseObject>() { public void done(List<ParseObject> scoreList, ParseException e) { if (e == null) { if (scoreList.size() > 0) { handler.sendEmptyMessage(0); } else { Toast.makeText(Login.this, "Hellow illegal", Toast.LENGTH_SHORT).show(); } Log.d(AppConstants.MY_TAG, "Retrieved " + scoreList.size() + " " + scoreList.toString() + " scores"); } else { Log.d(AppConstants.MY_TAG, "Error: " + e.getMessage()); } } }); }
public void showFavorites() { ParseQuery<Trainer> query = ParseQuery.getQuery("Trainer"); query.include("favorited_by"); query.whereEqualTo("favorited_by", SimpleUser.currentUserObject); query.findInBackground(new FindCallback<Trainer>() { public void done(List<Trainer> trainers, ParseException e) { hideProgressWheel(); if (e == null) { Log.d("DEBUG", "Retrieved " + trainers.size() + " trainers"); refreshFragment(trainers); } else { Log.d("DEBUG", "Error: " + e.getMessage()); } } }); }
@Override protected Integer doInBackground(String... params) { try { //Query Parse for the user's pings ParseQuery<ParseObject> query = ParseQuery.getQuery("FAQ_Category"); categoryList = new ArrayList<ParseObject>(query.find()); for (ParseObject category: categoryList) { ArrayList<ParseObject> questionQuery = new ArrayList<ParseObject>(category.getRelation("Questions").getQuery().find()); //Filler questionsList.add(questionQuery); } } catch (ParseException e) {return e.getCode();}//return exception code return 0;//no issues }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); ParseQuery<ParseObject> query = ParseQuery.getQuery("event_user"); query.whereEqualTo("userID", ParseUser.getCurrentUser().getObjectId() ); query.whereEqualTo("isPart", true); query.orderByDescending("createdAt"); query.findInBackground(new FindCallback<ParseObject>() { public void done(List<ParseObject> events, ParseException e) { if (e == null) { mParticipatedEvents= events; ProfileListAdapter adapter = new ProfileListAdapter(getListView().getContext(), mParticipatedEvents); setListAdapter(adapter); } else { } } }); }
private void initData() { String id = getArguments().getString(USER_ID); mLocalDb = LocalDb.getInstance(); mUser = mLocalDb.getCurrentUser(); mFollow = mUser.getFollow(); mIsCurrentUser = id == null || mUser.getObjectId().equals(id); if (!mIsCurrentUser) { ParseQuery query = new ParseQuery(Constants.USER_TABLE); try { mUser = (User) query.get(id); mFollow = mUser.getFollow(); } catch (ParseException e) { NotificationHelper.alert(getActivity(), getString(R.string.dialog_error_title), e.getMessage()); } } mMyRoom = mUser.getRoom(); }
/** * Limit 10000 by skip */ @NonNull @CheckReturnValue public static <R extends ParseObject> Observable<R> all(@NonNull final ParseQuery<R> query, int count) { final int limit = 1000; // limit limitation query.setSkip(0); query.setLimit(limit); Observable<R> find = find(query); for (int i = limit; i < count; i+= limit) { if (i >= 10000) break; // skip limitation query.setSkip(i); query.setLimit(limit); find.concatWith(find(query)); } return find.distinct(o -> o.getObjectId()); }
/** * Refreshes the DietitianList. That is, queries Parse for all ParseUsers whose isDietitian field is true and * repopulates the DietitianList with the result. If the query fails, the DietitianList remains * unchanged. * * @param callback Optional. The callback to invoke after completion. */ public void refresh(@Nullable final FindCallback<ParseUser> callback){ Log.d(TAG, "Refresh start"); notifyUpdateStart(); ParseQuery<ParseUser> query = ParseQuery.getQuery("_User"); query.whereEqualTo("isDietitian", true); query.findInBackground(new FindCallback<ParseUser>() { @Override public void done(List<ParseUser> refreshedDietitians, ParseException e) { if (e == null) { dietitians.clear(); dietitians.addAll(refreshedDietitians); } if (callback != null) { callback.done(refreshedDietitians, e); } notifyUpdateComplete(); } }); }
public void populateFavoriteTrainers() { showProgressWheel(); final TrainersListFragment finalFragment = fragment; String currentUserId = getLoggedInUserId(); // If userId is found; user has already signed up if (!currentUserId.equals("")) { ParseQuery<SimpleUser> query = ParseQuery.getQuery("SimpleUser"); query.whereEqualTo("objectId", currentUserId); query.getFirstInBackground(new GetCallback<SimpleUser>() { @Override public void done(SimpleUser simpleUser, ParseException e) { SimpleUser.currentUserObject = simpleUser; showFavorites(); } }); } else { // Ask the user to sign up launchLoginActivity(LOGIN_FOR_FAVORITES); } }
private void dietitianSearch(final String userId) { ParseQuery<ParseUser> query = ParseQuery.getQuery("_User"); query.whereEqualTo("objectId", userId); query.findInBackground(new FindCallback<ParseUser>() { @Override public void done(List<ParseUser> objects, ParseException e) { if (e == null) { if (!objects.isEmpty()) { ParseUser result = objects.get(0); ParseUser.getCurrentUser().put("myDietitian", result); giveAccess(result); } else Toast.makeText(cont, "User not found", Toast.LENGTH_LONG).show(); } else Log.e("SEARCH ERROR", "ERROR IN SEARCHING"); } }); }
public ArrayList<String> getChannels() { //channels is in hashmap now, this needs to be updated List<ParseObject> ob = null; ArrayList<String> channelsList = new ArrayList<String>(); ParseQuery<ParseObject> query = new ParseQuery<ParseObject>("Channels"); /*query.whereEqualTo("userID", getEmail()); try { ob = query.find(); } catch (ParseException e) { Log.e("Error", e.getMessage()); e.printStackTrace(); } for (ParseObject channels : ob) { channelsList = (ArrayList<String>) channels.get("channels"); }*/ return channelsList; }
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); } }); } }
@Override protected List<String> doAsyncTask(String... params) { final List<String> lista = new ArrayList<String>(); state = params[0]; try { ParseQuery<ParseObject> query = ParseQuery.getQuery("State"); query.whereEqualTo("name", state); ParseObject parseObject = query.getFirst(); ParseQuery<ParseObject> queryCity = ParseQuery.getQuery("City"); queryCity.whereEqualTo("id_state", parseObject.getInt("id_state")); List<ParseObject> parseObjects = queryCity.find(); for (ParseObject p : parseObjects){ lista.add(p.getString("name_city")); } return lista; } catch (Exception e) { return null; } }
private void addNewMessages() { String[] objectIds = {m_me.objectId, m_other.objectId}; ParseQuery<Message> query = ParseQuery.getQuery("Message"); query.whereContainedIn("fromObjectId", Arrays.asList(objectIds)); query.whereContainedIn("toObjectId", Arrays.asList(objectIds)); query.orderByAscending("createdAt"); query.findInBackground(new FindCallback<Message>() { public void done(List<Message> messages, ParseException e) { if (e == null) { // Set the value of global current user object for (int i = 0; i < messages.size(); i++) { Message message = messages.get(i); if (!m_messages.contains(message)) { messagesAdapter.add(message); lvMessages.setSelection(lvMessages.getCount() - 1); } } } else { Log.d("DEBUG", "Error: " + e.getMessage()); } } }); }
public void updateEmail(final String email, final String id) { Log.d("UserAPI", "start updateEmail"); ParseQuery<ParseUser> queryOne = ParseUser.getQuery(); queryOne.whereEqualTo(EMAIL, email); queryOne.findInBackground(new FindCallback<ParseUser>() { public void done(List<ParseUser> objects, ParseException e) { if (e == null) { for (ParseUser parseUser : objects) { if (parseUser.getObjectId().equals(id)) { ParseUser.getCurrentUser().put(EMAIL, email); } } } else { Log.d("UserAPI", "problem in updateEmail"); e.printStackTrace(); } } }); }
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()); } } }); }
private void populateMessageHistory() { String[] userIds = {currentUserId, recipientId}; ParseQuery<ParseObject> query = ParseQuery.getQuery("ParseMessage"); query.whereContainedIn("senderId", Arrays.asList(userIds)); query.whereContainedIn("recipientId", Arrays.asList(userIds)); query.orderByAscending("createdAt"); query.findInBackground(new FindCallback<ParseObject>() { @Override public void done(List<ParseObject> messageList, com.parse.ParseException e) { if (e == null) { for (int i = 0; i < messageList.size(); i++) { WritableMessage message = new WritableMessage(messageList.get(i).get("recipientId").toString(), messageList.get(i).get("messageText").toString()); if (messageList.get(i).get("senderId").toString().equals(currentUserId)) { messageAdapter.addMessage(message, MessageAdapter.DIRECTION_OUTGOING); } else { messageAdapter.addMessage(message, MessageAdapter.DIRECTION_INCOMING); } } } } }); }
@Override public void onMessageSent(MessageClient client, Message message, String recipientId) { final WritableMessage writableMessage = new WritableMessage(message.getRecipientIds().get(0), message.getTextBody()); //only add message to parse database if it doesn't already exist there ParseQuery<ParseObject> query = ParseQuery.getQuery("ParseMessage"); query.whereEqualTo("sinchId", message.getMessageId()); query.findInBackground(new FindCallback<ParseObject>() { @Override public void done(List<ParseObject> messageList, com.parse.ParseException e) { if (e == null) { if (messageList.size() == 0) { ParseObject parseMessage = new ParseObject("ParseMessage"); parseMessage.put("senderId", currentUserId); parseMessage.put("recipientId", writableMessage.getRecipientIds().get(0)); parseMessage.put("messageText", writableMessage.getTextBody()); parseMessage.put("sinchId", writableMessage.getMessageId()); parseMessage.saveInBackground(); messageAdapter.addMessage(writableMessage, MessageAdapter.DIRECTION_OUTGOING); } } } }); }
public UserViewAdapter(Context context) { super(context, new ParseQueryAdapter.QueryFactory<Photo>() { public ParseQuery<Photo> create() { // Get the current user's photos ParseQuery<Photo> photosFromCurrentUserQuery = new ParseQuery<Photo>("Photo"); photosFromCurrentUserQuery.whereEqualTo("user", ParseUser.getCurrentUser()); photosFromCurrentUserQuery.whereExists("thumbnail"); photosFromCurrentUserQuery.include("user"); photosFromCurrentUserQuery.orderByDescending("createdAt"); return photosFromCurrentUserQuery; } }); }
@Override protected void onDialogClosed(boolean positiveResult) { super.onDialogClosed(positiveResult); if(positiveResult){ try { ParseQuery<ParseObject> query = ParseQuery.getQuery("Pings"); query.whereEqualTo("User", ParseUser.getCurrentUser()); List<ParseObject>pingsList = query.find(); for(ParseObject p : pingsList) p.deleteInBackground(); Toast.makeText(getContext(), R.string.PingsCleared, Toast.LENGTH_SHORT).show(); } catch (Exception e){ Toast.makeText(getContext(), R.string.UnableToClearPings,Toast.LENGTH_LONG).show(); } } }