File tree Expand file tree Collapse file tree 1 file changed +12
-6
lines changed
library/src/main/java/com/firebase/ui Expand file tree Collapse file tree 1 file changed +12
-6
lines changed Original file line number Diff line number Diff line change @@ -147,12 +147,18 @@ public int getItemCount() {
147
147
}
148
148
149
149
public T getItem (int position ) {
150
- if (mModelClass != DataSnapshot .class ) {
151
- return mSnapshots .getItem (position ).getValue (mModelClass );
152
- }
153
- else {
154
- return (T ) mSnapshots .getItem (position );
155
- }
150
+ return parseSnapshot (mSnapshots .getItem (position ));
151
+ }
152
+
153
+ /**
154
+ * This method parses the DataSnapshot into the requested type. You can override it in subclasses
155
+ * to do custom parsing.
156
+ *
157
+ * @param snapshot the DataSnapshot to extract the model from
158
+ * @return the model extracted from the DataSnapshot
159
+ */
160
+ protected T parseSnapshot (DataSnapshot snapshot ) {
161
+ return snapshot .getValue (mModelClass );
156
162
}
157
163
158
164
public Firebase getRef (int position ) { return mSnapshots .getItem (position ).getRef (); }
You can’t perform that action at this time.
0 commit comments