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 ...
有人可以帮我吗