Skip to content

Instantly share code, notes, and snippets.

@senamit2708
Last active May 17, 2019 19:48
Show Gist options
  • Save senamit2708/e5831e82f7a3526306d2aa5cdc28d07e to your computer and use it in GitHub Desktop.
Save senamit2708/e5831e82f7a3526306d2aa5cdc28d07e to your computer and use it in GitHub Desktop.
how to reverse array list
.addSnapshotListener(new EventListener<QuerySnapshot>() {
@Override
public void onEvent(@Nullable QuerySnapshot value,
@Nullable FirebaseFirestoreException e) {
if (e!= null){
Log.w(TAG, "listen failed "+e);
return;
}
List<MessageModel> messageList = new ArrayList<>();
for (DocumentSnapshot doc : value){
String message = doc.getString("msg");
String time = doc.getString("tme");
String id = doc.getString("id");
Log.i(TAG,"loaded "+message);
messageList.add(new MessageModel(message, time, id));
}
Collections.reverse(messageList);
mMessageListLive.setValue(messageList);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment