private void showData(){
query = firebaseFirestore.collection("task").orderBy("time" , Query.Direction.DESCENDING);
listenerRegistration = query.addSnapshotListener(new EventListener<QuerySnapshot>() {
@Override
public void onEvent(@Nullable QuerySnapshot value, @Nullable FirebaseFirestoreException error) {
if (e!=null){
Log.d(TAG,"Error:"+e.getMessage());
}
else {
for (DocumentChange documentChange : value.getDocumentChanges()){
if (documentChange.getType() == DocumentChange.Type.ADDED){
String id = documentChange.getDocument().getId();
ToDoModel toDoModel = documentChange.getDocument().toObject(ToDoModel.class).withId(id);
mList.add(toDoModel);
adapter.notifyDataSetChanged();
}
}
listenerRegistration.remove();
}
}
});
}