I am trying to sort in the recyclerview the photos that are uploaded in order of time, but for some reason my code does not work.
The code of the adapter of the recyclerview:
private void setupAdapter() {
mPostAdapter = new FirebaseRecyclerAdapter<Post, PostHolder>(
Post.class,
R.layout.row_post,
PostHolder.class,
FirebaseUtils.getPostQuery()
) {
the code of the utils class:
public static DatabaseReference getPostRef() {
return FirebaseDatabase.getInstance().getReference("posts");
}
public static Query getPostQuery() {
return getPostRef().orderByChild("timeCreated");
}
public static DatabaseReference getMyPostRef() {
return FirebaseDatabase.getInstance().getReference("my_posts")
.child(getCurrentUser().getEmail().replace(".", ","));
}
Here is the database structure:
{
...
"my_posts" : {
"a@aa,com" : {
"-KgHOJHOGHAPGyBuVbF5" : true
},
"afaf@sg,com" : {
"-KgHXFz3NoshQNKbXz53" : true,
"-KgHZJFpkQ7lxx7HcxEV" : true
},
...
},
"posts" : {
"-KgHOJHOGHAPGyBuVbF5" : {
"numComments" : 0,
"numLikes" : 0,
"postId" : "-KgHOJHOGHAPGyBuVbF5",
"postImageUrl" : "post_images/image:47620",
"postText" : "",
"timeCreated" : 1490662278306
},
...
},
"posts_liked" : {
"dskato0603@gmail,com" : {
"-KgWIDHRyVoX4kHQlCvk" : true
}
},
"user_record" : {
"a@aa,com" : {
"posts" : [ "-KgHOJHOGHAPGyBuVbF5" ]
},
"jxjsjskss@kfks,com" : {
"comments" : [ "-KgLRZCT7A_OIZXwa5RD", "-KgLRaAybYi9p1AnO5tN", "-KgMUAKOc30PBRwm5icX" ],
"posts" : [ "-KgHiMD5jlUcnHcLWcAi", "-KgL3MrPw2D6-N6VACKF", "-KgLDQxqaxVQNs9WcdEW" ]
}
...
}
}