Firebase中的最后一个孩子的UID

时间:2018-11-20 05:14:12

标签: java android database firebase firebase-realtime-database

firebaseRecyclerAdapter = new FirebaseRecyclerAdapter<MessagesHelper, Chat.MessagesViewHolder>(options) {

        @Override
        protected void onBindViewHolder(@NonNull final Chat.MessagesViewHolder holder, final int position, @NonNull final MessagesHelper model) {
            holder.setMessage(model.getMessage());
            final String from_user = model.getFrom();
            final boolean Seen = model.isSeen();
            final String mType = model.getType();

            final String userId = getRef(position).getKey();
            final DatabaseReference mTimeReference = FirebaseDatabase.getInstance().getReference().child("Messages").child(MessageSenderId).child(MessageRecieverId);
            mTimeReference .addChildEventListener(new ChildEventListener() {
                @Override
                public void onChildAdded(DataSnapshot dataSnapshot, String s) {
                    MessagesHelper message = dataSnapshot.getValue(MessagesHelper.class);

                }

                @Override
                public void onChildChanged(DataSnapshot dataSnapshot, String s) {
                }

                @Override
                public void onChildRemoved(DataSnapshot dataSnapshot) {
                }

                @Override
                public void onChildMoved(DataSnapshot dataSnapshot, String s) {
                }

                @Override
                public void onCancelled(DatabaseError databaseError) {
                }
            });

在我结束本活动之前,我想获取最后一条消息的keyID并将其存储在sharedpreference或其他内容中...

所以当我重新打开该活动时,我只想在该keyID剩下的之后才加载消息...而在我关闭该活动之前再次加载,请用新的活动替换keyId ...

有人可以帮我吗

0 个答案:

没有答案