@@ -122,26 +122,46 @@ public long getItemId(int i) {
122
122
}
123
123
124
124
@ Override
125
- public View getView (int i , View view , ViewGroup viewGroup ) {
125
+ public View getView (int position , View view , ViewGroup viewGroup ) {
126
126
if (view == null ) {
127
127
view = mActivity .getLayoutInflater ().inflate (mLayout , viewGroup , false );
128
128
}
129
129
130
- T model = mSnapshots .getItem (i ).getValue (mModelClass );
130
+ T model = mSnapshots .getItem (position ).getValue (mModelClass );
131
131
132
132
// Call out to subclass to marshall this model into the provided view
133
- populateView (view , model );
133
+ populateView (view , model , position );
134
134
return view ;
135
135
}
136
136
137
137
/**
138
138
* Each time the data at the given Firebase location changes, this method will be called for each item that needs
139
- * to be displayed. The arguments correspond to the mLayout and mModelClass given to the constructor of this class.
139
+ * to be displayed. The first two arguments correspond to the mLayout and mModelClass given to the constructor of
140
+ * this class. The third argument is the item's position in the list.
140
141
* <p>
141
142
* Your implementation should populate the view using the data contained in the model.
143
+ * You should implement either this method or the other {@link FirebaseListAdapter#populateView(View, Object)} method
144
+ * but not both.
142
145
*
143
- * @param v The view to populate
144
- * @param model The object containing the data used to populate the view
146
+
147
+ * @param position The position in the list of the view being populated
148
+ */
149
+ protected void populateView (View v , T model , int position ) {
150
+ populateView (v , model );
151
+ }
152
+
153
+ /**
154
+ * This is a backwards compatible version of populateView.
155
+ * <p>
156
+ * You should implement either this method or the other {@link FirebaseListAdapter#populateView(View, Object, int)} method
157
+ * but not both.
158
+ *
159
+ * @see FirebaseListAdapter#populateView(View, Object, int)
160
+ *
161
+ * @param v The view to populate
162
+ * @param model The object containing the data used to populate the view
145
163
*/
146
- protected abstract void populateView (View v , T model );
164
+ protected void populateView (View v , T model ) {
165
+
166
+ }
147
167
}
0 commit comments