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 @@ -113,12 +113,18 @@ public int getCount() {
113
113
114
114
@ Override
115
115
public T getItem (int position ) {
116
- if (mModelClass != DataSnapshot .class ) {
117
- return mSnapshots .getItem (position ).getValue (mModelClass );
118
- }
119
- else {
120
- return (T ) mSnapshots .getItem (position );
121
- }
116
+ return parseSnapshot (mSnapshots .getItem (position ));
117
+ }
118
+
119
+ /**
120
+ * This method parses the DataSnapshot into the requested type. You can override it in subclasses
121
+ * to do custom parsing.
122
+ *
123
+ * @param snapshot the DataSnapshot to extract the model from
124
+ * @return the model extracted from the DataSnapshot
125
+ */
126
+ protected T parseSnapshot (DataSnapshot snapshot ) {
127
+ return snapshot .getValue (mModelClass );
122
128
}
123
129
124
130
public Firebase getRef (int position ) { return mSnapshots .getItem (position ).getRef (); }
You can’t perform that action at this time.
0 commit comments