Skip to content

Commit eb8623a

Browse files
authored
Speulative fix for #1210 (#1216)
2 parents b90a6ec + e21d9b4 commit eb8623a

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

constants.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ project.ext {
88
targetSdk = 27
99
minSdk = 14
1010

11-
firebaseVersion = '11.8.0'
11+
firebaseVersion = '12.0.1'
1212
supportLibraryVersion = '27.1.0'
1313
architectureVersion = '1.1.0'
1414
kotlinVersion = '1.2.30'

firestore/src/main/java/com/firebase/ui/firestore/FirestoreArray.java

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import com.google.firebase.firestore.FirebaseFirestoreException;
1010
import com.google.firebase.firestore.ListenerRegistration;
1111
import com.google.firebase.firestore.Query;
12+
import com.google.firebase.firestore.QueryDocumentSnapshot;
1213
import com.google.firebase.firestore.QueryListenOptions;
1314
import com.google.firebase.firestore.QuerySnapshot;
1415

@@ -95,30 +96,32 @@ public void onEvent(QuerySnapshot snapshots, FirebaseFirestoreException e) {
9596
}
9697

9798
private void onDocumentAdded(DocumentChange change) {
98-
mSnapshots.add(change.getNewIndex(), change.getDocument());
99-
notifyOnChildChanged(ChangeEventType.ADDED, change.getDocument(), change.getNewIndex(), -1);
99+
QueryDocumentSnapshot snapshot = change.getDocument();
100+
mSnapshots.add(change.getNewIndex(), snapshot);
101+
notifyOnChildChanged(ChangeEventType.ADDED, snapshot, change.getNewIndex(), -1);
100102
}
101103

102104
private void onDocumentRemoved(DocumentChange change) {
103105
mSnapshots.remove(change.getOldIndex());
104-
notifyOnChildChanged(
105-
ChangeEventType.REMOVED, change.getDocument(), -1, change.getOldIndex());
106+
QueryDocumentSnapshot snapshot = change.getDocument();
107+
notifyOnChildChanged(ChangeEventType.REMOVED, snapshot, -1, change.getOldIndex());
106108
}
107109

108110
private void onDocumentModified(DocumentChange change) {
111+
QueryDocumentSnapshot snapshot = change.getDocument();
109112
if (change.getOldIndex() == change.getNewIndex()) {
110113
// Document modified only
111-
mSnapshots.set(change.getNewIndex(), change.getDocument());
112-
notifyOnChildChanged(ChangeEventType.CHANGED, change.getDocument(),
114+
mSnapshots.set(change.getNewIndex(), snapshot);
115+
notifyOnChildChanged(ChangeEventType.CHANGED, snapshot,
113116
change.getNewIndex(), change.getNewIndex());
114117
} else {
115118
// Document moved and possibly also modified
116119
mSnapshots.remove(change.getOldIndex());
117-
mSnapshots.add(change.getNewIndex(), change.getDocument());
120+
mSnapshots.add(change.getNewIndex(), snapshot);
118121

119-
notifyOnChildChanged(ChangeEventType.MOVED, change.getDocument(),
122+
notifyOnChildChanged(ChangeEventType.MOVED, snapshot,
120123
change.getNewIndex(), change.getOldIndex());
121-
notifyOnChildChanged(ChangeEventType.CHANGED, change.getDocument(),
124+
notifyOnChildChanged(ChangeEventType.CHANGED, snapshot,
122125
change.getNewIndex(), change.getNewIndex());
123126
}
124127
}

0 commit comments

Comments
 (0)