Class AdminFacilitiesAdapter

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

public class AdminFacilitiesAdapter extends androidx.recyclerview.widget.RecyclerView.Adapter<com.example.rocket_launch.admin.AdminFacilitiesAdapter.ViewHolder>
Adapter for displaying a list of facilities in a RecyclerView. Handles data binding, updates, and long-click interactions for the admin panel. Author: Pouyan
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static interface 
    Interface for handling long-click events on facility items.

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

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

    Constructors
    Constructor
    Description
    Constructs the adapter with a list of facilities and a long-click listener.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Returns the total number of facility items in the list.
    void
    onBindViewHolder(com.example.rocket_launch.admin.AdminFacilitiesAdapter.ViewHolder holder, int position)
    Binds data to the ViewHolder for a specific position in the list.
    com.example.rocket_launch.admin.AdminFacilitiesAdapter.ViewHolder
    onCreateViewHolder(android.view.ViewGroup parent, int viewType)
    Creates a new ViewHolder when the RecyclerView needs it.
    void
    removeFacility(int position)
    Removes a facility from the list at the specified position.
    void
    updateData(List<User> newFacilities)
    Updates the list of facilities with new data and refreshes the RecyclerView.

    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

    • AdminFacilitiesAdapter

      public AdminFacilitiesAdapter(List<User> facilities, AdminFacilitiesAdapter.OnItemLongClickListener listener)
      Constructs the adapter with a list of facilities and a long-click listener.
      Parameters:
      facilities - The list of facilities to display.
      listener - The listener for handling long-click events. Author: Pouyan
  • Method Details

    • onCreateViewHolder

      @NonNull public com.example.rocket_launch.admin.AdminFacilitiesAdapter.ViewHolder onCreateViewHolder(@NonNull android.view.ViewGroup parent, int viewType)
      Creates a new ViewHolder when the RecyclerView needs it.
      Specified by:
      onCreateViewHolder in class androidx.recyclerview.widget.RecyclerView.Adapter<com.example.rocket_launch.admin.AdminFacilitiesAdapter.ViewHolder>
      Parameters:
      parent - The parent ViewGroup.
      viewType - The type of the view (not used here).
      Returns:
      A new ViewHolder instance. Author: Pouyan
    • onBindViewHolder

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

      public int getItemCount()
      Returns the total number of facility items in the list.
      Specified by:
      getItemCount in class androidx.recyclerview.widget.RecyclerView.Adapter<com.example.rocket_launch.admin.AdminFacilitiesAdapter.ViewHolder>
      Returns:
      The number of facilities. Author: Pouyan
    • removeFacility

      public void removeFacility(int position)
      Removes a facility from the list at the specified position.
      Parameters:
      position - The position of the facility to remove. Author: Pouyan
    • updateData

      public void updateData(List<User> newFacilities)
      Updates the list of facilities with new data and refreshes the RecyclerView.
      Parameters:
      newFacilities - The updated list of facilities. Author: Pouyan