RVAdapter

public class RVAdapter extends RecyclerView.Adapter<RVAdapter.PostViewHolder>

Adapter that provides the Posts and/or Events of a org.codethechange.culturemesh.models.Network to displayed, scrollable lists

Constructors

RVAdapter

public RVAdapter(List<FeedItem> netPosts, OnItemClickListener listener, Context context)

Initialize instance fields with provided parameters

Parameters:
  • netPosts – List of objects to represent in the displayed list
  • listener – Listener to handle clicks on list tiems
  • contextContext in which the list will be displayed

Methods

getItemCount

public int getItemCount()

Get the number of items to display

Returns:Number of items in the list of items to display (RVAdapter.netPosts)

getNetPosts

public List<FeedItem> getNetPosts()

Get the items being represented as elements of the displayed list (not just the ones currently visible).

Returns:Items represented as elements in the displayed list

getUserAttendingEvents

public Set<Long> getUserAttendingEvents()

Get the events in this network that the user is attending, which affects some aspects of the event UI.

Returns:a set of the ids of the events.

onBindViewHolder

public void onBindViewHolder(PostViewHolder pvh, int i)

Link the provided PostViewHolder to an object in the list RVAdapter.netPosts, which is used to fill the fields in the PostViewHolder

Parameters:
  • pvh – Item in the displayed list whose fields to fill with information
  • i – Index of object in RVAdapter.netPosts that will serve as the source of information to fill into the displayed list item

onCreateViewHolder

public PostViewHolder onCreateViewHolder(ViewGroup parent, int viewType)

Create a new PostViewHolder from a View created by inflating the layout described by R.layout.post_view.

Parameters:
Returns:

A new PostViewHolder for inclusion in the displayed list