Created
March 28, 2015 02:52
-
-
Save edwardinubuntu/9c1579896d91e281fbbb to your computer and use it in GitHub Desktop.
Parse Query Story Object
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
protected void loadStories(final boolean more) { | |
final ParseQuery<ParseObject> parseQuery = ParseQuery.getQuery("Story"); | |
parseQuery.include("StoryTeller"); | |
parseQuery.orderByDescending("createdAt"); | |
parseQuery.include("ideaPointer"); | |
parseQuery.include("graphicPointer"); | |
ParseQuery<Flag> flagQuery = ParseQuery.getQuery(Flag.class); | |
flagQuery.whereEqualTo("Object", "Story"); | |
flagQuery.whereEqualTo("Status", "Close"); | |
parseQuery.whereDoesNotMatchKeyInQuery("objectId", "ObjID", flagQuery); | |
parseQuery.whereNotContainedIn("status", DailyKind.getAnonymousStoriesStatusList(getActivity())); | |
parseQuery.setLimit(10); | |
parseQuery.whereContainedIn("language", DailyKind.getLanguageCollection(getActivity())); | |
parseQuery.setCachePolicy(ParseQuery.CachePolicy.CACHE_THEN_NETWORK); | |
parseQuery.setMaxCacheAge(DailyKind.QUERY_AT_LEAST_CACHE_AGE); | |
if (more) { | |
ParseQuery storyCountQuery = ParseQuery.getQuery("Story"); | |
storyCountQuery.setCachePolicy(ParseQuery.CachePolicy.CACHE_ELSE_NETWORK); | |
storyCountQuery.setMaxCacheAge(DailyKind.QUERY_MAX_CACHE_AGE); | |
storyCountQuery.whereContainedIn("language", DailyKind.getLanguageCollection(getActivity())); | |
parseQuery.whereNotContainedIn("status", DailyKind.getAnonymousStoriesStatusList(getActivity())); | |
storyCountQuery.countInBackground(new CountCallback() { | |
@Override | |
public void done(int totalCount, ParseException e) { | |
if (totalCount > userActivities.size()) { | |
parseQuery.setSkip(userActivities.size()); | |
queryToCallBack(parseQuery, more); | |
} else { | |
Log.d(DailyKind.TAG, "End of query."); | |
} | |
} | |
}); | |
} else { | |
userActivities.clear(); | |
queryToCallBack(parseQuery, more); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment