Package com.example.rocket_launch.admin
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 ClassesModifier and TypeClassDescriptionstatic interfaceInterface for handling profile deletion events.Nested classes/interfaces inherited from class androidx.recyclerview.widget.RecyclerView.Adapter
androidx.recyclerview.widget.RecyclerView.Adapter.StateRestorationPolicy -
Constructor Summary
ConstructorsConstructorDescriptionAdminProfilesAdapter(List<User> users) Constructor for initializing the adapter with a list of user profiles. -
Method Summary
Modifier and TypeMethodDescriptionintReturns the number of user profiles in the list.voidonBindViewHolder(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.ViewHolderonCreateViewHolder(android.view.ViewGroup parent, int viewType) Inflates the layout for an individual user profile item.voidremoveProfile(int position) Removes a profile from the list and notifies the adapter.voidSets the listener for handling profile deletion.voidupdateData(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
-
Constructor Details
-
AdminProfilesAdapter
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:
onCreateViewHolderin classandroidx.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:
onBindViewHolderin classandroidx.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:
getItemCountin classandroidx.recyclerview.widget.RecyclerView.Adapter<com.example.rocket_launch.admin.AdminProfilesAdapter.ViewHolder>- Returns:
- The total number of user profiles. Author: Pouyan
-
updateData
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
Sets the listener for handling profile deletion.- Parameters:
listener- The listener to handle long-press delete events. Author: Pouyan
-