Ordered events list in descending time order, so newest is at the top of the list

This commit is contained in:
Graham Jones
2022-03-24 09:02:09 +00:00
parent 883b22a634
commit dc8a57c60e

View File

@@ -22,8 +22,10 @@ import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.firestore.DocumentReference; import com.google.firebase.firestore.DocumentReference;
import com.google.firebase.firestore.DocumentSnapshot; import com.google.firebase.firestore.DocumentSnapshot;
import com.google.firebase.firestore.FirebaseFirestore; import com.google.firebase.firestore.FirebaseFirestore;
import com.google.firebase.firestore.Query;
import com.google.firebase.firestore.QueryDocumentSnapshot; import com.google.firebase.firestore.QueryDocumentSnapshot;
import com.google.firebase.firestore.QuerySnapshot; import com.google.firebase.firestore.QuerySnapshot;
import com.google.firebase.firestore.core.OrderBy;
import org.json.JSONArray; import org.json.JSONArray;
import org.json.JSONException; import org.json.JSONException;
@@ -218,6 +220,7 @@ public class WebApiConnection {
String userId = FirebaseAuth.getInstance().getCurrentUser().getUid(); String userId = FirebaseAuth.getInstance().getCurrentUser().getUid();
mDb.collection("Events") //.where("userId", "==", userId) mDb.collection("Events") //.where("userId", "==", userId)
.whereEqualTo("userId", userId) .whereEqualTo("userId", userId)
.orderBy("dataTime", Query.Direction.ASCENDING)
.get() .get()
.addOnCompleteListener(new OnCompleteListener<QuerySnapshot>() { .addOnCompleteListener(new OnCompleteListener<QuerySnapshot>() {
@Override @Override