Firebase在父级观察/查询并忽略其中一个子级

时间:2018-05-22 05:47:31

标签: android firebase firebase-realtime-database

我刚开始使用firebase,我有这样的数据视图。

enter image description here

我像这样观察/查询 con-LD-iQlmxyvo2t3mvwER

private void retrieveConversation(String conversationID) {

    Query queryRoom = FirebaseDatabase.getInstance().getReference().child("Conversation").child(conversationID);

    queryRoom.keepSynced(true);

    queryRoom.addValueEventListener(new ValueEventListener() {
        @Override
        public void onDataChange(DataSnapshot dataSnapshot) {
            Conversation conversation = dataSnapshot.getValue(Conversation.class);
            if (conversation != null) {
                conversation = updateConversation(conversation);
                mainMessage.conversations.put(conversation.getId(), conversation);
                EventBus.getDefault().post(new ChatAdapter.AddMessage());
                EventBus.getDefault().post(new ChatDetailAdapter.ReceiveMessage());

                if (chatDetailBlock != null) {
                    if (conversation.getId().equals(chatDetailID)) {
                            chatDetailBlock.run();
                        chatDetailBlock = null;
                        chatDetailID = null;
                    }
                }
            }
        }

        @Override
        public void onCancelled(DatabaseError databaseError) {

        }
    });
}

问题是我需要忽略" 消息"子节点,监听/观察其余节点并更新对象(或至少限制消息数量)。有可能吗?

0 个答案:

没有答案