Class AdminProfilesAdapter

java.lang.Object
androidx.recyclerview.widget.RecyclerView.Adapter<com.example.rocket_launch.admin.AdminProfilesAdapter.ViewHolder>
com.example.rocket_launch.admin.AdminProfilesAdapter

public class AdminProfilesAdapter extends androidx.recyclerview.widget.RecyclerView.Adapter<com.example.rocket_launch.admin.AdminProfilesAdapter.ViewHolder>
Adapter for displaying a list of user profiles in the admin view. Provides functionality for long-press deletion of profiles. Author: Pouyan
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static interface 
    Interface for handling profile deletion events.

    Nested classes/interfaces inherited from class androidx.recyclerview.widget.RecyclerView.Adapter

    androidx.recyclerview.widget.RecyclerView.Adapter.StateRestorationPolicy
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructor for initializing the adapter with a list of user profiles.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Returns the number of user profiles in the list.
    void
    onBindViewHolder(com.example.rocket_launch.admin.AdminProfilesAdapter.ViewHolder holder, int position)
    Binds user data to the ViewHolder for the given position.
    com.example.rocket_launch.admin.AdminProfilesAdapter.ViewHolder
    onCreateViewHolder(android.view.ViewGroup parent, int viewType)
    Inflates the layout for an individual user profile item.
    void
    removeProfile(int position)
    Removes a profile from the list and notifies the adapter.
    void
    Sets the listener for handling profile deletion.
    void
    updateData(List<User> newUsers)
    Updates the data in the adapter with a new list of users.

    Methods inherited from class androidx.recyclerview.widget.RecyclerView.Adapter

    bindViewHolder, createViewHolder, findRelativeAdapterPositionIn, getItemId, getItemViewType, getStateRestorationPolicy, hasObservers, hasStableIds, notifyDataSetChanged, notifyItemChanged, notifyItemChanged, notifyItemInserted, notifyItemMoved, notifyItemRangeChanged, notifyItemRangeChanged, notifyItemRangeInserted, notifyItemRangeRemoved, notifyItemRemoved, onAttachedToRecyclerView, onBindViewHolder, onDetachedFromRecyclerView, onFailedToRecycleView, onViewAttachedToWindow, onViewDetachedFromWindow, onViewRecycled, registerAdapterDataObserver, setHasStableIds, setStateRestorationPolicy, unregisterAdapterDataObserver

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • AdminProfilesAdapter

      public AdminProfilesAdapter(List<User> users)
      Constructor for initializing the adapter with a list of user profiles.
      Parameters:
      users - List of users to display in the RecyclerView. Author: Pouyan
  • Method Details

    • onCreateViewHolder

      @NonNull public com.example.rocket_launch.admin.AdminProfilesAdapter.ViewHolder onCreateViewHolder(@NonNull android.view.ViewGroup parent, int viewType)
      Inflates the layout for an individual user profile item.
      Specified by:
      onCreateViewHolder in class androidx.recyclerview.widget.RecyclerView.Adapter<com.example.rocket_launch.admin.AdminProfilesAdapter.ViewHolder>
      Parameters:
      parent - The parent ViewGroup.
      viewType - The type of view (unused here).
      Returns:
      A ViewHolder instance for the user profile item. Author: Pouyan
    • onBindViewHolder

      public void onBindViewHolder(@NonNull com.example.rocket_launch.admin.AdminProfilesAdapter.ViewHolder holder, int position)
      Binds user data to the ViewHolder for the given position.
      Specified by:
      onBindViewHolder in class androidx.recyclerview.widget.RecyclerView.Adapter<com.example.rocket_launch.admin.AdminProfilesAdapter.ViewHolder>
      Parameters:
      holder - The ViewHolder to bind data to.
      position - The position of the user in the list. Author: Pouyan
    • getItemCount

      public int getItemCount()
      Returns the number of user profiles in the list.
      Specified by:
      getItemCount in class androidx.recyclerview.widget.RecyclerView.Adapter<com.example.rocket_launch.admin.AdminProfilesAdapter.ViewHolder>
      Returns:
      The total number of user profiles. Author: Pouyan
    • updateData

      public void updateData(List<User> newUsers)
      Updates the data in the adapter with a new list of users.
      Parameters:
      newUsers - The updated list of users. Author: Pouyan
    • removeProfile

      public void removeProfile(int position)
      Removes a profile from the list and notifies the adapter.
      Parameters:
      position - The position of the profile to remove. Author: Pouyan
    • setOnProfileDeleteListener

      public void setOnProfileDeleteListener(AdminProfilesAdapter.OnProfileDeleteListener listener)
      Sets the listener for handling profile deletion.
      Parameters:
      listener - The listener to handle long-press delete events. Author: Pouyan