I want to make SNS android application. Posts that users have posted and relations("Likes") are loaded from my Parse.com server. I succeeded in loading posts using parseQueryAdapter
and ListView
in a Fragment
. But relation ("Likes") query loading event can not be loaded.
Asked
Active
Viewed 318 times
1

Manuel
- 14,274
- 6
- 57
- 130

Jun Seok Kim
- 31
- 6
2 Answers
0
By default ParseQuery will not fetch relationship objects. You need to include relationship objects in ParseQuery.
ParseQuery<Post> postQuery= new ParseQuery<Post>("Post");
postQuery.include("likes");

Rutvij Shah
- 113
- 4
- 10
-
oh.. I don't know include method. I find ParseQuery reference . I don't know the way using that. I want to show a example link using this method. – Jun Seok Kim Mar 21 '15 at 09:59
-
I think this way is unefficient because it may need more request per item at getItemView() method.. – Jun Seok Kim Mar 21 '15 at 10:03
-
Nope. It won'tt require more request. Its way to fetch associated object with the object in same call. – Rutvij Shah Mar 22 '15 at 04:22
-
How do I use this method include()? "Likes" need to call getReltion("Likes) method of current user. – Jun Seok Kim Mar 24 '15 at 10:56
0
ParseQueryAdapter<Post> mainAdapter;
ParseQueryAdapter.QueryFactory<Post> factory;
factory = new ParseQueryAdapter.QueryFactory<Post>() {
@Override
public ParseQuery<Post> create() {
ParseQuery query = new ParseQuery("Post");
query.whereEqualTo("Post_Liked", true);
return query;
}
};
mainAdapter = new ParseQueryAdapter<Post>(this, factory) {
@Override
public View getItemView(final Post object, View v, ViewGroup parent) {
if (v == null) {
v = View.inflate(getContext(), R.layout.your_list_view, null);
}
return v;
}};
So why don't you just make it so that the user can set a post to "liked" or "not liked" with true and false respectively?

dave
- 575
- 4
- 19
-
hmm... I think this way is for only one user. When each user is loading posts, bacause each of users have different liking posts, boolean column is different for them.. if I perform getRelation() and change the boolean column and Totally load posts with ParseQuery , I have to use many requests at Parse.com... – Jun Seok Kim Mar 24 '15 at 10:28