UsersListAdapter

public class UsersListAdapter extends RecyclerView.Adapter<UsersListAdapter.ViewHolder>

This Adapter is used for viewing the subscribed users of a network.

Fields

context

Context context

Context in which the list is being displayed

Constructors

UsersListAdapter

public UsersListAdapter(Context context, ArrayList<User> users)

Create a new object by instantiating instance fields with parameters

Parameters:
  • contextContext in which the list is displayed
  • users – List of Users to display in the list

Methods

getItemCount

public int getItemCount()

Get the number of items in the list of objects to display

Returns:Number of items in list to display

getUsers

public ArrayList<User> getUsers()

Get the list of objects to display

Returns:List of objects represented in list

onBindViewHolder

public void onBindViewHolder(ViewHolder holder, int position)

Fill the name and profile picture fields of holder with the contents of an item in UsersListAdapter.users.

Parameters:
  • holderViewHolder whose fields to fill with information
  • position – Index of item in list of users to use as source of information for filling

onCreateViewHolder

public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType)

Create a new UsersListAdapter.ViewHolder from a View inflated from R.layout.user_list_item and with parent parent

Parameters:
Returns:

The created UsersListAdapter.ViewHolder