Skip to content

Commit 8ffc04b

Browse files
committed
Fixed a few populateView implementations
The position parameter is no longer optional, so update the docs to always have it. Screenshots are not updated, so may still use the old signature.
1 parent 984c056 commit 8ffc04b

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ protected void onCreate(Bundle savedInstanceState) {
327327
328328
mAdapter = new FirebaseListAdapter<ChatMessage>(this, ChatMessage.class, android.R.layout.two_line_list_item, ref) {
329329
@Override
330-
protected void populateView(View view, ChatMessage chatMessage) {
330+
protected void populateView(View view, ChatMessage chatMessage, int position) {
331331
((TextView)view.findViewById(android.R.id.text1)).setText(chatMessage.getName());
332332
((TextView)view.findViewById(android.R.id.text2)).setText(chatMessage.getMessage());
333333
@@ -381,7 +381,7 @@ protected void onCreate(Bundle savedInstanceState) {
381381

382382
mAdapter = new FirebaseListAdapter<ChatMessage>(this, ChatMessage.class, android.R.layout.two_line_list_item, ref) {
383383
@Override
384-
protected void populateView(View view, ChatMessage chatMessage) {
384+
protected void populateView(View view, ChatMessage chatMessage, int position) {
385385
((TextView)view.findViewById(android.R.id.text1)).setText(chatMessage.getName());
386386
((TextView)view.findViewById(android.R.id.text2)).setText(chatMessage.getMessage());
387387
}
@@ -449,7 +449,7 @@ recycler.setLayoutManager(new LinearLayoutManager(this));
449449
450450
mAdapter = new FirebaseRecyclerViewAdapter<ChatMessage, ChatMessageViewHolder>(ChatMessage.class, android.R.layout.two_line_list_item, ChatMessageViewHolder.class, mRef) {
451451
@Override
452-
public void populateViewHolder(ChatMessageViewHolder chatMessageViewHolder, ChatMessage chatMessage) {
452+
public void populateViewHolder(ChatMessageViewHolder chatMessageViewHolder, ChatMessage chatMessage, int position) {
453453
chatMessageViewHolder.nameText.setText(chatMessage.getName());
454454
chatMessageViewHolder.messageText.setText(chatMessage.getMessage());
455455
}

codelabs/chat/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -282,14 +282,14 @@ Let's take this in chunks: first we'll create a Java class to represent each mes
282282
mListAdapter = new FirebaseListAdapter<ChatMessage>(this, ChatMessage.class,
283283
android.R.layout.two_line_list_item, mFirebaseRef) {
284284
@Override
285-
protected void populateView(View v, ChatMessage model) {
285+
protected void populateView(View v, ChatMessage model, int position) {
286286
((TextView)v.findViewById(android.R.id.text1)).setText(model.getName());
287287
((TextView)v.findViewById(android.R.id.text2)).setText(model.getText());
288288
}
289289
};
290290
setListAdapter(mListAdapter);
291291

292-
The FirebaseListAdapter maps the data from your Firebase database into the ListView that you added to the layout. It creates a new instance of your `two_line_list_item` for each `ChatMessage` and calls the `populateView method`. We override this method and put the name and text in the correct subviews.
292+
The FirebaseListAdapter maps the data from your Firebase database into the ListView that you added to the layout. It creates a new instance of your `two_line_list_item` for each `ChatMessage` and calls the `populateView` method. We override this method and put the name and text in the correct subviews.
293293

294294
![MainActivity code](images/5_6.png)
295295

0 commit comments

Comments
 (0)