RVCommentAdapter

public class RVCommentAdapter extends RecyclerView.Adapter<RVCommentAdapter.PostReplyViewHolder>

Adapter that populates a UI list with comments

Constructors

RVCommentAdapter

public RVCommentAdapter(List<PostReply> comments, OnItemClickListener listener, Context context)

Store parameters in instance fields

Parameters:
  • comments – List of comments to display in scrollable list to user
  • listener – Will be called whenever an item is clicked
  • contextContext within which the list will be displayed

Methods

getItemCount

public int getItemCount()

Get the number of comments in the list

Returns:Number of comments in list

onBindViewHolder

public void onBindViewHolder(PostReplyViewHolder pvh, int i)

Fill in the fields of pvh with the information stored in the PostReply at position i in the list of comments

Parameters:
  • pvhView in the list whose fields will be filled-in
  • i – Index of PostReply in RVCommentAdapter.comments to use as the source of information to fill with

onCreateViewHolder

public PostReplyViewHolder onCreateViewHolder(ViewGroup parent, int viewType)

Create a PostReplyViewHolder for parent with a View inflated from R.layout.comment_view

Parameters:
Returns:

The PostReplyViewHolder associated with the inflated View