File tree Expand file tree Collapse file tree 1 file changed +7
-3
lines changed
app/src/main/java/com/tiansirk/countryquiz/data Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -137,11 +137,15 @@ public void onFailure(@NonNull Exception e) {
137
137
});
138
138
}
139
139
140
- public Task <Void > saveLevels (String userId , List <? extends TEntity > entities ) {
140
+ public Task <Void > saveLevels (String parentDocumentId , List <? extends TEntity > entities ) {
141
141
WriteBatch batch = db .batch ();
142
- DocumentReference userDocumentReference = collectionReference .document (userId );
143
- DocumentReference levelDocumentReference = userDocumentReference . collection ( LEVELS_SUBCOLLECTION_NAME ). document ();
142
+ DocumentReference userDocumentReference = collectionReference .document (parentDocumentId );
143
+
144
144
for (TEntity tEntity : entities ){
145
+ if (Level .class .isInstance (tEntity )){
146
+ ((Level )tEntity ).setUserId (parentDocumentId );
147
+ }
148
+ DocumentReference levelDocumentReference = userDocumentReference .collection (LEVELS_SUBCOLLECTION_NAME ).document ();
145
149
batch .set (levelDocumentReference , tEntity );
146
150
}
147
151
return batch .commit ().addOnFailureListener (activity , new OnFailureListener () {
You can’t perform that action at this time.
0 commit comments