project tree image in this link
I am developing a social media app
In the Firebase database, There will be Users node,posts node,likes node and request type nodes
Users nodes contains fields which represents users details and it has a uid which is like a key
Under the posts node, there will be a postskey within it there will be the details of the posts like uid,profileimage,postimage, description,date,time,fullname The uid in the posts node is the uid in the Users node
I successfully uploaded images into the firebase storage and its url would be in the postimage field within the child node
To retrieve the particular users posts and display it in the particular users profile I tried this code which I enclosed in the images
But the posts of the user doesn't shows and white blank activity only shows up
Can u guide me to achieve my expected result I am not good in English Sorry,if you cannot understand my question because of my poor English
within OnCreate ,
mAuth=FirebaseAuth.getInstance();
currentUserID=mAuth.getCurrentUser().getUid();
PostsRef=FirebaseDatabase.getInstance().getReference().child("Posts");
myPostsList=(RecyclerView)findViewById(R.id.my_all_posts_list);
myPostsList.setHasFixedSize(true);
LinearLayoutManager linearLayoutManager=new LinearLayoutManager(this);
linearLayoutManager.setReverseLayout(true);
linearLayoutManager.setStackFromEnd(true);
myPostsList.setLayoutManager(linearLayoutManager);
DisplayMyAllPosts();
within Displaymyallposts method
private void DisplayMyAllPosts() {
Query myPostsQuery=PostsRef.orderByChild("uid").startAt(currentUserID).endAt(currentUserID+"\uf8ff");
FirebaseRecyclerOptions<Posts> options=new FirebaseRecyclerOptions.Builder<Posts>().setQuery(myPostsQuery,Posts.class).build();
FirebaseRecyclerAdapter<Posts,MyPostsViewHolder> firebaseRecyclerAdapter=new FirebaseRecyclerAdapter<Posts, MyPostsViewHolder>(options) {
@Override
protected void onBindViewHolder(@NonNull MyPostsViewHolder holder, int position, @NonNull Posts model) {
holder.fullname.setText(model.getFullname());
holder.date.setText(model.getDate());
holder.time.setText(model.getTime());
holder.description.setText(model.getDescription());
Picasso.get().load(model.getProfileimage()).into(holder.profileimage);
Picasso.get().load(model.getPostimage()).into(holder.postImage);
}
@NonNull
@Override
public MyPostsViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
View view=LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.all_posts_layout,viewGroup,false);
MyPostsViewHolder viewHolder=new MyPostsViewHolder(view);
return viewHolder;
}
};
myPostsList.setAdapter(firebaseRecyclerAdapter);
}
public static class MyPostsViewHolder extends RecyclerView.ViewHolder{
TextView fullname,date,time,description;
CircleImageView profileimage;
ImageView postImage;
public MyPostsViewHolder(@NonNull View itemView) {
super(itemView);
fullname=itemView.findViewById(R.id.post_user_name);
date=itemView.findViewById(R.id.post_date);
time=itemView.findViewById(R.id.post_time);
description=itemView.findViewById(R.id.post_description);
profileimage=itemView.findViewById(R.id.post_profile_image);
postImage=itemView.findViewById(R.id.post_image);
}
}