@@ -133,7 +133,7 @@ public void onChanged(EventType type, int index, int oldIndex) {
133
133
* combination of <code>limit()</code>, <code>startAt()</code>, and <code>endAt()</code>
134
134
*/
135
135
public FirebaseRecyclerViewAdapter (Class <T > modelClass , int modelLayout , Class <VH > viewHolderClass , Firebase ref ) {
136
- this (modelClass , modelLayout , viewHolderClass , (Query )ref );
136
+ this (modelClass , modelLayout , viewHolderClass , (Query ) ref );
137
137
}
138
138
139
139
@@ -175,11 +175,39 @@ public VH onCreateViewHolder(ViewGroup parent, int viewType) {
175
175
}
176
176
}
177
177
@ Override
178
- public void onBindViewHolder (VH viewHolder , int i ) {
179
- T model = getItem (i );
180
- populateViewHolder (viewHolder , model );
178
+ public void onBindViewHolder (VH viewHolder , int position ) {
179
+ T model = getItem (position );
180
+ populateViewHolder (viewHolder , model , position );
181
181
}
182
182
183
- abstract public void populateViewHolder (VH viewHolder , T model );
183
+ /**
184
+ * Each time the data at the given Firebase location changes, this method will be called for each item that needs
185
+ * to be displayed. The first two arguments correspond to the mLayout and mModelClass given to the constructor of
186
+ * this class. The third argument is the item's position in the list.
187
+ * <p>
188
+ * Your implementation should populate the view using the data contained in the model.
189
+ * You should implement either this method or the other {@link FirebaseRecyclerViewAdapter#populateViewHolder(VH, Object)} method
190
+ * but not both.
191
+ *
192
+ * @param viewHolder The view to populate
193
+ * @param model The object containing the data used to populate the view
194
+ * @param position The position in the list of the view being populated
195
+ */
196
+ protected void populateViewHolder (VH viewHolder , T model , int position ) {
197
+ populateViewHolder (viewHolder , model );
198
+ };
199
+ /**
200
+ * This is a backwards compatible version of populateViewHolder.
201
+ * <p>
202
+ * You should implement either this method or the other {@link FirebaseListAdapter#populateView(View, Object, int)} method
203
+ * but not both.
204
+ *
205
+ * @see FirebaseListAdapter#populateView(View, Object, int)
206
+ *
207
+ * @param viewHolder The view to populate
208
+ * @param model The object containing the data used to populate the view
209
+ */
210
+ protected void populateViewHolder (VH viewHolder , T model ) {
211
+ };
184
212
185
213
}
0 commit comments