Skip to content

Commit e3ec786

Browse files
SUPERCILEXsamtstern
authored andcommitted
Add documentation about SnapshotParser (#1079)
1 parent 0731699 commit e3ec786

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

database/README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,18 @@ with our chat example:
130130
.build();
131131
```
132132

133+
If you need to customize how your model class is parsed, you can use a custom `SnapshotParser`:
134+
135+
```java
136+
...setQuery(..., new SnapshotParser<Chat>() {
137+
@NonNull
138+
@Override
139+
public Chat parseSnapshot(@NonNull DataSnapshot snapshot) {
140+
return ...;
141+
}
142+
});
143+
```
144+
133145
Next create the `FirebaseRecyclerAdapter` object. You should already have a `ViewHolder` subclass
134146
for displaying each item. In this case we will use a custom `ChatHolder` class:
135147

firestore/README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,18 @@ FirestoreRecyclerOptions<Chat> options = new FirestoreRecyclerOptions.Builder<Ch
126126
.build();
127127
```
128128

129+
If you need to customize how your model class is parsed, you can use a custom `SnapshotParser`:
130+
131+
```java
132+
...setQuery(..., new SnapshotParser<Chat>() {
133+
@NonNull
134+
@Override
135+
public Chat parseSnapshot(@NonNull DocumentSnapshot snapshot) {
136+
return ...;
137+
}
138+
});
139+
```
140+
129141
Next create the `FirestoreRecyclerAdapter` object. You should already have a `ViewHolder` subclass
130142
for displaying each item. In this case we will use a custom `ChatHolder` class:
131143

0 commit comments

Comments
 (0)