我有以下片段,我想在其中显示来自当前用户关注的用户的查询。
public class FollowingFragment extends PostListFragment {
private static final String TAG = "FollowingFragment";
private String followingId = new String();
public FeedFragment() {}
@Override
public Query getQuery(DatabaseReference databaseReference) {
return databaseReference.child("posts")
.orderByChild("uid").equalTo(followingId);
}
}
我不知道如何将用户的关注列表一一放在“关注”中。
我的 firebase 实时数据库是:
{
"post-comments" : {
"-MRA4RN-mbh4abKk8d77" : {
"-MRsgJ9w8orEp2P8Au1K" : {
"text" : "1st",
"uid" : "asethasrhsrheglkjeg"
},
"-MRshp5kTzIVnfw1HiGX" : {
"text" : "2nd\n2nd",
"uid" : "asethasrhsrheglkjeg"
},
"-MRsiOdTVzJSIOpA1bkM" : {
"text" : "s",
"uid" : "asethasrhsrheglkjeg"
}
},
"-MRDwB6Q_gS7durHeKUP" : {
"-MRsiBS2iE3IIM2_Yd0l" : {
"text" : "d",
"uid" : "asethasrhsrheglkjeg"
},
"-MRsiByVH7fsDPKdgACg" : {
"text" : "",
"uid" : "asethasrhsrheglkjeg"
},
"-MRsiCKcIa9fhc1YDu3E" : {
"text" : "",
"uid" : "asethasrhsrheglkjeg"
},
"-MRsiCb5leJNnqa8-utQ" : {
"text" : "",
"uid" : "asethasrhsrheglkjeg"
}
}
},
"posts" : {
"-MRA4RN-mbh4abKk8d77" : {
"body" : "i am in pain",
"starCount" : 0,
"title" : "waba laba dub dub",
"uid" : "asethasrhsrheglkjeg"
},
"-MRDwB6Q_gS7durHeKUP" : {
"body" : "sdfgdsdfgfdg\n\n\n\n",
"starCount" : 0,
"title" : "zdfgvbdzfgbzdf\n\n\ndfgszdgzdgtfg",
"uid" : "aworgiajerogjargjnb"
},
"-MRsdB34LPrRNPCMyToY" : {
"body" : "sdfw",
"starCount" : 0,
"title" : "sdf",
"uid" : "asethasrhsrheglkjeg"
}
},
"users" : {
"aworgiajerogjargjnb" : {},
"aS04z1PoT0YsnQUBcZEpBe7JRhU2" : {},
"asethasrhsrheglkjeg" : {
"following" : {
"aworgiajerogjargjnb" : true,
"asethasrhsrheglkjeg" : true
}
}
}
}
修改了数据库中的一些id。
现在,我想从用户节点获取“followingUsers”列表并显示“uid”等于“followingUsers”的帖子。