嵌套的FirestoreRecyclerAdapter不显示任何内容

时间:2020-05-06 20:04:34

标签: firebase google-cloud-firestore android-recyclerview nestedrecyclerview

我正在尝试实现Instagram风格的评论部分。我有一个集合组查询/ comments,可以使用RecyclerView很好地显示评论。 在父级FirestoreRecyclerAdapter onBindViewHolder内部,我有这个。

           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);
                }

在此块之外,我将ReplyRecycler设置为嵌套适配器;我设置了线性布局管理器并开始收听。

但是这什么也没做。实际上,对cQuery执行addSnapShotLinstener不会返回任何结果。没有错误,没有数据。

0 个答案:

没有答案