0

I make an app where the logged in user can see the other users from Firestore database ( they are in a recyclerView ) . Each item of the recycler view has a button called "Add friend". I want to send a friend request to that specific user when I click that button.

I have a tab called "Pending requests" where the logged in can see the received friend requests.

I am using an adapter for recycler view. In MyAdapter.java I have this :

    public class myViewHolder extends RecyclerView.ViewHolder{

        TextView usernamerecycle;
        Button addbutton;
        View rootview;

        private FirebaseAuth mAuth;
        FirebaseFirestore firestore;
        
        public myViewHolder(@NonNull View itemView) {
            super(itemView);
            rootview = itemView;
            usernamerecycle = itemView.findViewById(R.id.usernamerecycler);
            addbutton = itemView.findViewById(R.id.addfriendbutton);
            
            
            addbutton.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Log.d(TAG, "item clicked: " + getAdapterPosition() + "user= " + userArrayList.get(getAdapterPosition()).username );
                }
            });

        }
    }

My question is : When I send a friend request to a particular user which should be the steps? Should I create a collection called "Requests" for each user and for example when I click the button for "ralu" then a new Request to appear in ralu's "Requests" collection ? After that to display all the pending requests from there in "Pending requests" tab of that user ? Do you have an example or something of how should I do this? How can I put data in another user collection ( other than the logged in user )? Please !!!

enter image description here

Daiana
  • 19
  • 6

0 Answers0