本文整理汇总了Java中com.parse.ParseQuery.setLimit方法的典型用法代码示例。如果您正苦于以下问题:Java ParseQuery.setLimit方法的具体用法?Java ParseQuery.setLimit怎么用?Java ParseQuery.setLimit使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.parse.ParseQuery
的用法示例。
在下文中一共展示了ParseQuery.setLimit方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: queryParseForLast24Hours
import com.parse.ParseQuery; //导入方法依赖的package包/类
private void queryParseForLast24Hours() {
final int myUpdateNumber = ++mMostRecentMapUpdate;
ParseQuery<Record> mapQuery = Record.getQuery();
mapQuery.include("user");
Date onDayAgo = getNowMinus24Hours();
mapQuery.whereGreaterThanOrEqualTo("createdAt", onDayAgo);
mapQuery.orderByDescending("createdAt");
mapQuery.setLimit(100);
// Kick off the query in the background
mapQuery.findInBackground(new FindCallback<Record>() {
@Override
public void done(List<Record> records, ParseException e) {
Log.e(TAG, "=== findInBackground === records = " + records);
if (e != null) {
Log.e(TAG, "=== findInBackground === records = " + records);
return;
}
/*
* Make sure we're processing results from
* the most recent update, in case there
* may be more than one in progress.
*/
if (myUpdateNumber != mMostRecentMapUpdate) {
return;
}
EventBus.getDefault()
.post(new LocationChangedEvent(records));
}
});
}
示例2: all
import com.parse.ParseQuery; //导入方法依赖的package包/类
/**
* 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());
}
示例3: refresh
import com.parse.ParseQuery; //导入方法依赖的package包/类
/**
* Refreshes the SnackList. That is, queries Parse for the current user's SnackEntrys and
* repopulates the SnackList with the result. If the query fails, the SnackList remains
* unchanged.
*
* @param callback Optional. The callback to invoke after completion.
*/
public void refresh(@Nullable final FindCallback<SnackEntry> callback){
Log.d(TAG, "Refresh start");
notifyUpdateStart();
ParseQuery<SnackEntry> query = ParseQuery.getQuery(SnackEntry.class);
query.orderByDescending("createdAt");
query.whereEqualTo("owner", targetUser);
query.setLimit(10);
query.findInBackground(new FindCallback<SnackEntry>() {
@Override
public void done(List<SnackEntry> refreshedSnacks, ParseException e) {
if (e == null) {
snacks.clear();
snacks.addAll(refreshedSnacks);
}
if (callback != null) {
callback.done(refreshedSnacks, e);
}
notifyUpdateComplete(e);
}
});
}
示例4: loadMoreData
import com.parse.ParseQuery; //导入方法依赖的package包/类
public void loadMoreData(Integer currentCount){
if(!isUpdating){
notifyUpdateStart();
ParseQuery<SnackEntry> query = ParseQuery.getQuery(SnackEntry.class);
query.orderByDescending("createdAt");
query.whereEqualTo("owner", targetUser);
query.setLimit(10);
query.setSkip(currentCount);
query.findInBackground(new FindCallback<SnackEntry>() {
@Override
public void done(List<SnackEntry> moreSnacks, ParseException e) {
if (e == null) {
snacks.addAll(moreSnacks);
}
notifyUpdateComplete(e);
}
});
}
}
示例5: getAnimeList
import com.parse.ParseQuery; //导入方法依赖的package包/类
@Override
public List<Anime> getAnimeList() {
ArrayList<Anime> animeList = new ArrayList<>();
int limit = 10000;
int page = 0;
try {
boolean endReached = false;
do {
ParseQuery<AnimeRecord> query = AnimeRecord.getQuery();
query.setLimit(limit);
query.setSkip(page * limit);
List<AnimeRecord> list = query.find();
if (list != null) {
for (AnimeRecord animeRecord : list) {
Anime anime = AnimeRecord.toAnime(animeRecord);
if (anime != null)
animeList.add(anime);
}
if (list.size() < limit)
endReached = true;
else
page++;
} else
endReached = true;
} while (!endReached);
} catch (ParseException e) {
e.printStackTrace();
}
WriteLog.appendLog(TAG,"Anime loaded from server: " + animeList.size());
return animeList;
}
示例6: loadInternal
import com.parse.ParseQuery; //导入方法依赖的package包/类
private Observable<LoadResult<ExampleMessage>> loadInternal(@NonNull String conversationId, @NonNull LoadQuery.Type type, long timestamp) {
final ParseQuery<ParseObject> parseQuery = new ParseQuery<>(MessagesTable.NAME);
parseQuery.whereEqualTo(MessagesTable.Fields.CHAT, ParseObject.createWithoutData(ChatTable.NAME, conversationId));
parseQuery.addDescendingOrder(MessagesTable.Fields.CREATED_AT);
if (type == Type.OLDER) {
parseQuery.whereLessThan(MessagesTable.Fields.CREATED_AT, new Date(timestamp));
}
else if (type == Type.NEWER) {
parseQuery.whereGreaterThan(MessagesTable.Fields.CREATED_AT, new Date(timestamp));
}
parseQuery.setLimit(MAX_CHUNK_SIZE);
parseQuery.include(MessagesTable.Fields.IMAGE);
return mParseHelper.find(parseQuery)
.doOnNext(mSortMessagesAscending)
.flatMap(Observable::from)
.map(in -> ParseUtils.from(in, mParseHelper))
.toList()
.map(messages -> {
final boolean canLoadOlder;
final boolean canLoadNewer;
if (type == Type.OLDER) {
canLoadOlder = !messages.isEmpty();
canLoadNewer = true; // This will be ignored in any case since we are loading older messages
}
else if (type == Type.NEWER) {
canLoadOlder = true; // This will be ignored in any case since we are loading newer messages
canLoadNewer = !messages.isEmpty();
}
else {
canLoadOlder = !messages.isEmpty();
canLoadNewer = !messages.isEmpty();
}
return new LoadResult<>(messages, canLoadOlder, canLoadNewer);
})
.subscribeOn(Schedulers.io());
}
示例7: receiveMessage
import com.parse.ParseQuery; //导入方法依赖的package包/类
private void receiveMessage() {
// Construct query to execute
ParseQuery<Message> query = ParseQuery.getQuery(Message.class);
// Configure limit and sort order
query.setLimit(MAX_CHAT_MESSAGES_TO_SHOW);
Log.d("me", ParseUser.getCurrentUser().getUsername().toString());
String[] names = {ParseUser.getCurrentUser().getString("username"), profiles.displayProfile.getUserName()};
query.whereContainedIn("userId", Arrays.asList(names));
query.whereContainedIn("Receiver", Arrays.asList(names));
query.orderByAscending("createdAt");
// Execute query to fetch all messages from Parse asynchronously
// This is equivalent to a SELECT query with SQL
query.findInBackground(new FindCallback<Message>() {
public void done(List<Message> messages, ParseException e) {
if (e == null) {
if (mMessages != null) {
mMessages.clear();
mMessages.addAll(messages);
mAdapter.notifyDataSetChanged(); // update adapter
lvChat.invalidate(); // redraw listview
}
} else {
Log.d("message", "Error: " + e.getMessage());
}
}
});
}
示例8: fetchMessages
import com.parse.ParseQuery; //导入方法依赖的package包/类
/**
* Fetches a full list of messages between two users.
*
* @param user1 The first user
* @param user2 The second user
* @param callback The callback to invoke upon completion.
*/
private void fetchMessages(ParseUser user1, ParseUser user2, int limit, int skip, final FindCallback<Message> callback) {
List<ParseQuery<Message>> orQueries = new ArrayList<>();
ParseQuery<Message> oredQuery;
isUpdating = true;
Log.d("Conversations", "Skip is " + skip);
orQueries.add(ParseQuery.getQuery(Message.class)
.whereEqualTo(Message.FROM_KEY, user1)
.whereEqualTo(Message.TO_KEY, user2)
);
orQueries.add(ParseQuery.getQuery(Message.class)
.whereEqualTo(Message.TO_KEY, user1)
.whereEqualTo(Message.FROM_KEY, user2)
);
oredQuery = ParseQuery.or(orQueries);
oredQuery.include(Message.FROM_KEY).include(Message.TO_KEY);
oredQuery.orderByDescending("createdAt");
oredQuery.setLimit(limit);
oredQuery.setSkip(skip);
oredQuery.findInBackground(new FindCallback<Message>() {
@Override
public void done(List<Message> messages, ParseException e) {
if (e == null) {
if (messages.size() > 0) {
ParseUser fromUser = messages.get(0).getFromUser();
ParseUser toUser = messages.get(0).getToUser();
// Null users not allowed
if (fromUser == null || toUser == null) {
messages.clear();
}
}
callback.done(messages, e);
isUpdating = false;
}
}
});
}
示例9: onResume
import com.parse.ParseQuery; //导入方法依赖的package包/类
@Override
protected void onResume() {
super.onResume();
mCurrentUser = ParseUser.getCurrentUser();
mFriendsRelation = mCurrentUser.getRelation(ParseConstants.KEY_FRIENDS_RELATION);
setProgressBarIndeterminateVisibility(true);
ParseQuery<ParseUser> query = ParseUser.getQuery();
query.orderByAscending(ParseConstants.KEY_USERNAME);
query.setLimit(1000);
query.findInBackground(new FindCallback<ParseUser>() {
@Override
public void done(List<ParseUser> users, ParseException e) {
setProgressBarIndeterminateVisibility(false);
if (e == null) {
// Success
mUsers = users;
String[] usernames = new String[mUsers.size()];
int i = 0;
for(ParseUser user : mUsers) {
usernames[i] = user.getUsername();
i++;
}
if (mGridView.getAdapter() == null) {
UserAdapter adapter = new UserAdapter(EditFriendsActivity.this, mUsers);
mGridView.setAdapter(adapter);
}
else {
((UserAdapter)mGridView.getAdapter()).refill(mUsers);
}
addFriendCheckmarks();
}
else {
Log.e(TAG, e.getMessage());
AlertDialog.Builder builder = new AlertDialog.Builder(EditFriendsActivity.this);
builder.setMessage(e.getMessage())
.setTitle(R.string.error_title)
.setPositiveButton(android.R.string.ok, null);
AlertDialog dialog = builder.create();
dialog.show();
}
}
});
}
示例10: chooseFederalMember
import com.parse.ParseQuery; //导入方法依赖的package包/类
/**
* This is called when we press the search button beside the Federal fields.
* @param view
*/
public void chooseFederalMember(View view)
{
final ProgressDialog progressDialog = new ProgressDialog(this);
progressDialog.setTitle(getString(R.string.loading));
progressDialog.setMessage(getString(R.string.fetching_data));
progressDialog.setCancelable(false);
Utils.displayWaitingDialogWithTimeout(Setup4.this, progressDialog);
final String objectName = "Federal_Members";
/*
This block of code will fetch members from the internet every single time. The commented
block underneath this will first try to fetch from the Parse local datastore before internet.
*/
if(Utils.isNetworkAvailable(Setup4.this)){ //fetch from parse online
ParseQuery<ParseObject> query = ParseQuery.getQuery(objectName);
query.setLimit(500);
query.findInBackground(new FindCallback<ParseObject>() {
@Override
public void done(List<ParseObject> parseObjects, ParseException e) {
if(e!=null)
return;
if(parseObjects.size() == 0) {
Toast.makeText(Setup4.this, "No MPs found, try sending a bug report.", Toast.LENGTH_LONG).show();
return;
}
//converts to Members then assigns them to the proper global variable
convertParseObjectToMembers(objectName, parseObjects);
//only start the next activity if user hasn't cancelled the loading dialog
//and it hasn't timed out
if (progressDialog.isShowing()) {
progressDialog.dismiss();
Intent intent = new Intent(Setup4.this, MemberListActivity.class);
intent.putParcelableArrayListExtra("members", federal_members);
intent.putExtra("title", getString(R.string.fedMPs));
intent.putExtra("province", "Canada");
startActivityForResult(intent, Utils.FED_MEMB);
}
}
});
} else{
Toast.makeText(Setup4.this, "Could not fetch MPs. Check your network Connection", Toast.LENGTH_SHORT).show();
progressDialog.dismiss();
}
}
示例11: chooseProvincialMember
import com.parse.ParseQuery; //导入方法依赖的package包/类
/**
* This is called when we press the search button beside the Provincial fields.
* @param view
*/
public void chooseProvincialMember(View view)
{
final ProgressDialog progressDialog = new ProgressDialog(this);
progressDialog.setTitle(getString(R.string.loading));
progressDialog.setMessage(getString(R.string.fetching_data));
progressDialog.setCancelable(false);
Utils.displayWaitingDialogWithTimeout(Setup4.this, progressDialog);
final String objectName = Utils.convertProvinceToShortProvince(mProvince)+"_Members";
/*
This block of code will fetch members from the internet every single time. The commented
block underneath this will first try to fetch from the Parse local datastore before internet.
*/
if(Utils.isNetworkAvailable(Setup4.this)){ //fetch from parse online
ParseQuery<ParseObject> query = ParseQuery.getQuery(objectName);
query.setLimit(250); //should be more than enough to fetch provincial MPs from any province
query.findInBackground(new FindCallback<ParseObject>() {
@Override
public void done(List<ParseObject> parseObjects, ParseException e) {
if(e!=null)
return;
if(parseObjects.size() == 0) {
Toast.makeText(Setup4.this, "Could not fetch MPs, try sending a bug report.", Toast.LENGTH_LONG).show();
return;
}
//converts to Members then assigns them to the proper global variable
convertParseObjectToMembers(objectName, parseObjects);
//only start the next activity if user hasn't cancelled the loading dialog
//and it hasn't timed out
if (progressDialog.isShowing()) {
progressDialog.dismiss();
Intent intent = new Intent(Setup4.this, MemberListActivity.class);
intent.putParcelableArrayListExtra("members", provincial_members);
intent.putExtra("title", getString(R.string.provMPs) + " - " + Utils.convertProvinceToShortProvince(mProvince));
intent.putExtra("province", mProvince);
startActivityForResult(intent, Utils.PROV_MEMB);
}
}
});
} else{
Toast.makeText(Setup4.this, "Could not fetch MPs. Check your network Connection", Toast.LENGTH_SHORT).show();
progressDialog.dismiss();
}
}
示例12: reselectFederalMember
import com.parse.ParseQuery; //导入方法依赖的package包/类
/**
* Called when user taps on federal members name in the main activity. This should bring them
* to the federal member selector so they can quickly change their federal member without
* repeating all of setup.
* @param view
*/
public void reselectFederalMember(View view)
{
//start loading dialog with a timeout
final ProgressDialog progressDialog = new ProgressDialog(this);
progressDialog.setTitle(getString(R.string.loading));
progressDialog.setMessage(getString(R.string.fetching_data));
progressDialog.setCancelable(false);
Utils.displayWaitingDialogWithTimeout(MainActivity.this, progressDialog);
final String objectName = "Federal_Members";
final String title = getString(R.string.fedMPs);
/*
This block of code will fetch members from the internet every single time. The commented
block underneath this will first try to fetch from the Parse local datastore before internet.
*/
if(Utils.isNetworkAvailable(MainActivity.this)){ //fetch from parse online
ParseQuery<ParseObject> query = ParseQuery.getQuery(objectName);
query.setLimit(500);
query.findInBackground(new FindCallback<ParseObject>() {
@Override
public void done(List<ParseObject> parseObjects, ParseException e) {
if(e!=null)
return;
if(parseObjects.size() == 0) {
Toast.makeText(MainActivity.this, "Could not fetch MPs, try sending a bug report.", Toast.LENGTH_LONG).show();
return;
}
//converts to Members then assigns them to the proper global variable
//convertParseObjectToMembers(objectName, parseObjects);
MainActivity.this.gotMembers(progressDialog, parseObjects, title, Utils.FED_MEMB, "Canada");
//save the newly found MPs
//ParseObject.pinAllInBackground(parseObjects);
}
});
} else{
Toast.makeText(MainActivity.this, "Could not fetch MPs. Check your network Connection", Toast.LENGTH_SHORT).show();
progressDialog.dismiss();
}
}
示例13: reselectProvincialMember
import com.parse.ParseQuery; //导入方法依赖的package包/类
public void reselectProvincialMember(View view)
{
//start loading dialog with a timeout
final ProgressDialog progressDialog = new ProgressDialog(this);
progressDialog.setTitle(getString(R.string.loading));
progressDialog.setMessage(getString(R.string.fetching_data));
progressDialog.setCancelable(false);
Utils.displayWaitingDialogWithTimeout(MainActivity.this, progressDialog);
final String objectName = Utils.convertProvinceToShortProvince(mProvince)+"_Members";
final String title = getString(R.string.provMPs) + " - " + Utils.convertProvinceToShortProvince(mProvince);
/*
This block of code will fetch members from the internet every single time. The commented
block underneath this will first try to fetch from the Parse local datastore before internet.
*/
if(Utils.isNetworkAvailable(MainActivity.this)){ //fetch from parse online
ParseQuery<ParseObject> query = ParseQuery.getQuery(objectName);
query.setLimit(250); //should be more than enough to fetch provincial MPs from any province
query.findInBackground(new FindCallback<ParseObject>() {
@Override
public void done(List<ParseObject> parseObjects, ParseException e) {
if(e!=null)
return;
if(parseObjects.size() == 0) {
Toast.makeText(MainActivity.this, "Could not fetch MPs, try sending a bug report.", Toast.LENGTH_LONG).show();
return;
}
//converts to Members then assigns them to the proper global variable
//convertParseObjectToMembers(objectName, parseObjects);
MainActivity.this.gotMembers(progressDialog, parseObjects, title, Utils.PROV_MEMB, mProvince);
//save the newly found MPs
//ParseObject.pinAllInBackground(parseObjects);
}
});
} else{
Toast.makeText(MainActivity.this, "Could not fetch MPs. Check your network Connection", Toast.LENGTH_SHORT).show();
progressDialog.dismiss();
}
}
示例14: loadConversationList
import com.parse.ParseQuery; //导入方法依赖的package包/类
/**
* Load the conversation list from Parse server and save the date of last
* message that will be used to load only recent new messages
*/
private void loadConversationList()
{
ParseQuery<ParseObject> q = ParseQuery.getQuery("Chat");
if (convList.size() == 0)
{
// load all messages...
ArrayList<String> al = new ArrayList<String>();
al.add(buddy);
al.add(UserList.user.getUsername());
q.whereContainedIn("sender", al);
q.whereContainedIn("receiver", al);
}
else
{
// load only newly received message..
if (lastMsgDate != null)
q.whereGreaterThan("createdAt", lastMsgDate);
q.whereEqualTo("sender", buddy);
q.whereEqualTo("receiver", UserList.user.getUsername());
}
q.orderByDescending("createdAt");
q.setLimit(30);
q.findInBackground(new FindCallback<ParseObject>() {
@Override
public void done(List<ParseObject> li, ParseException e)
{
if (li != null && li.size() > 0)
{
for (int i = li.size() - 1; i >= 0; i--)
{
ParseObject po = li.get(i);
Conversation c = new Conversation(po
.getString("message"), po.getCreatedAt(), po
.getString("sender"));
convList.add(c);
if (lastMsgDate == null
|| lastMsgDate.before(c.getDate()))
lastMsgDate = c.getDate();
adp.notifyDataSetChanged();
}
}
handler.postDelayed(new Runnable() {
@Override
public void run()
{
if (isRunning)
loadConversationList();
}
}, 1000);
}
});
}
示例15: refresh
import com.parse.ParseQuery; //导入方法依赖的package包/类
/**
* Refreshes the conversations for the current user. Up to 100 messages are fetched.
*
* @param callback The callback to invoke upon completion.
*/
public void refresh(@Nullable final FindCallback<Message> callback){
List<ParseQuery<Message>> orQueries = new ArrayList<>();
ParseQuery<Message> oredQuery;
isUpdating = true;
orQueries.add(ParseQuery.getQuery(Message.class)
.whereEqualTo(Message.FROM_KEY, ParseUser.getCurrentUser())
);
orQueries.add(ParseQuery.getQuery(Message.class)
.whereEqualTo(Message.TO_KEY, ParseUser.getCurrentUser())
);
oredQuery = ParseQuery.or(orQueries);
oredQuery.include(Message.FROM_KEY).include(Message.TO_KEY);
oredQuery.orderByDescending("createdAt");
oredQuery.setLimit(100);
oredQuery.findInBackground(new FindCallback<Message>() {
@Override
public void done(List<Message> messages, ParseException e) {
if(e == null){
Conversations.this.clear();
ParseObject.pinAllInBackground(PINNED_MESSAGES_LABEL, messages);
for(Message message : messages){
Group group = new Group(message.getFromUser(), message.getToUser());
// If the size is less than 2, the from user and to user are equal, which
// is not allowed.
if(group.size() < 2){
message.unpinInBackground(PINNED_MESSAGES_LABEL);
continue;
}
// Null members are not allowed
if(group.hasNullMember()){
message.unpinInBackground(PINNED_MESSAGES_LABEL);
continue;
}
List<Message> conversation = get(group);
if(conversation == null){
conversation = new ArrayList<>();
put(group, conversation);
}
conversation.add(message);
}
lastUpdateUser = ParseUser.getCurrentUser();
notifyRefresh();
}
if(callback != null){
callback.done(messages, e);
}
isUpdating = false;
}
});
}