0

I'm trying to achieve an Instagram style comment section. I have a collection group query /comments and can display comments just fine with RecyclerView. Inside of the parent FirestoreRecyclerAdapter onBindViewHolder I have this.

           DocumentSnapshot snapshot = getSnapshots().getSnapshot(holder.getAdapterPosition());
            String commentId = snapshot.getId();
            System.out.println("[CommentID: ]" + commentId);

            Query rQuery = mFirestore.collectionGroup("comments")
                    .whereEqualTo("postId", commentId)
                    .orderBy("timestamp", Query.Direction.DESCENDING)
                    .limit(50);

            FirestoreRecyclerOptions<SubCommentModel> options = new FirestoreRecyclerOptions.Builder<SubCommentModel>()
                    .setQuery(rQuery, SubCommentModel.class).build();

            RecyclerView replyRecycler = holder.reply_recycler;

            rAdapter = new FirestoreRecyclerAdapter<SubCommentModel, ReplyTypeViewHolder>(options) {
                @Override
                protected void onBindViewHolder(@NonNull ReplyTypeViewHolder holder, int position, @NonNull SubCommentModel model) {
                    final SimpleDateFormat FORMAT  = new SimpleDateFormat(
                            "MM/dd/yyyy", Locale.US);

                    ((ReplyTypeViewHolder) holder).author_name.setText(model.getAuthor());
                    ((ReplyTypeViewHolder) holder).comment_text.setText(model.getComment());
                    ((ReplyTypeViewHolder) holder).time_stamp.setText(FORMAT.format(model.getTimestamp()));
                }

                @NonNull
                @Override
                public ReplyTypeViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
                    View view;
                    view = LayoutInflater.from(parent.getContext()).inflate(R.layout.comment_item, parent, false);
                    return new ReplyTypeViewHolder(view);
                }

Outside of this block, I set replyRecycler to the nested adapter; I set up Linear Layout Manager and start listening.

However this does nothing. In fact doing addSnapShotLinstener to cQuery returns nothing. No error and no data.

Christopher Moore
  • 15,626
  • 10
  • 42
  • 52
Herthz Blond
  • 11
  • 1
  • 4
  • where you see nothing happening, on the frontend tring to display this? or yo refer to not getting the data from firestore? – Soni Sol May 07 '20 at 18:09
  • Both actually. There's nothing on the frontend and when I do cQuery.addSnapshotListener I get neither error nor data. – Herthz Blond May 07 '20 at 18:43

0 Answers0