Package com.example.rocket_launch.admin
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 ClassesModifier and TypeClassDescriptionstatic interfaceInterface 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
ConstructorsConstructorDescriptionAdminFacilitiesAdapter(List<User> facilities, AdminFacilitiesAdapter.OnItemLongClickListener listener) Constructs the adapter with a list of facilities and a long-click listener. -
Method Summary
Modifier and TypeMethodDescriptionintReturns the total number of facility items in the list.voidonBindViewHolder(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.ViewHolderonCreateViewHolder(android.view.ViewGroup parent, int viewType) Creates a new ViewHolder when the RecyclerView needs it.voidremoveFacility(int position) Removes a facility from the list at the specified position.voidupdateData(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
-
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:
onCreateViewHolderin classandroidx.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:
onBindViewHolderin classandroidx.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:
getItemCountin classandroidx.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
Updates the list of facilities with new data and refreshes the RecyclerView.- Parameters:
newFacilities- The updated list of facilities. Author: Pouyan
-