RVAdapter.PostViewHolder

static class PostViewHolder extends RecyclerView.ViewHolder

Stores the View elements of each item in the displayed list. Instances of this class are linked to objects in RVAdapter.netPosts by RVAdapter.onBindViewHolder(PostViewHolder,int), which fills the fields with content from the object.

Fields

comment1Layout

RelativeLayout comment1Layout

Layout within which the two displayed comments are defined

cv

CardView cv

The View for the displayed list item

eventDescription

TextView eventDescription

Description of the Event

eventDetailsLL

LinearLayout eventDetailsLL

Layout within which the details section of the displayed list item is defined

eventLocation

TextView eventLocation

Where the Event will take place

eventTime

TextView eventTime

Time of the Event

images

ImageView[] images

Array of all image displays

layout

ConstraintLayout layout

Layout within which the displayed list item is defined

personName

TextView personName

Text fields for both Post and Event information

personPhoto

ImageView personPhoto

Display images with the displayed list item

post

boolean post

Whether this instance is configured to display the information for a Post or for a Event. true if it is for a Post

Constructors

PostViewHolder

PostViewHolder(View itemView)

Initialize instance fields by retrieving UI elements by their IDs in the provided View

Parameters:
  • itemView – Canvas upon which the displayed list item is built. Should already have the needed fields and other elements.

Methods

bind

public void bind(FeedItem item, OnItemClickListener listener)

Set the displayed list item’s listener that handles clicks to that of the provided listener

Parameters:
  • item – The clicked-on item which will be passed to the listener’s OnItemClickListener.onItemClick(FeedItem)method when the item is clicked
  • listener – Listener to handle all clicks on items in the list

hideEventViews

void hideEventViews()

This instance will display the information from a Post, so hide all the fields that describe Events

hidePostViews

void hidePostViews()

This instance will display the information from a Event, so hide all the fields that describe Posts

isPost

public boolean isPost()

Check whether the instance is displaying information for a Post or a Event

Returns:true if displaying information for a Post. false if for an Event