Package com.example.breeze_seas
Class AdminBrowseEventsAdapter
java.lang.Object
androidx.recyclerview.widget.RecyclerView.Adapter<AdminBrowseEventsAdapter.EventViewHolder>
com.example.breeze_seas.AdminBrowseEventsAdapter
public class AdminBrowseEventsAdapter
extends androidx.recyclerview.widget.RecyclerView.Adapter<AdminBrowseEventsAdapter.EventViewHolder>
Adapter for the RecyclerView in the AdminBrowseEvents screen.
Binds a list of
Event objects to corresponding UI elements,
including event details, dates, and capacities.
Also handles user interactions such as clicking on an event to view details
or clicking the delete button to remove an event.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classHolds references to the UI components for a single event row to avoid repeated findViewById calls.static interfaceInterface definition for a callback to be invoked when an event item is clicked.static interfaceInterface definition for a callback to be invoked when an event's delete button is pressed.Nested classes/interfaces inherited from class androidx.recyclerview.widget.RecyclerView.Adapter
androidx.recyclerview.widget.RecyclerView.Adapter.StateRestorationPolicy -
Constructor Summary
ConstructorsConstructorDescriptionAdminBrowseEventsAdapter(List<Event> eventList, AdminBrowseEventsAdapter.OnEventClickListener listener, AdminBrowseEventsAdapter.OnEventDeleteListener deleteListener) Constructs a new AdminBrowseEventsAdapter. -
Method Summary
Modifier and TypeMethodDescriptionvoidFilters the displayed list to events whose name or description contains the query.intReturns the total number of items in the data set held by the adapter.voidonBindViewHolder(AdminBrowseEventsAdapter.EventViewHolder holder, int position) Called by the RecyclerView to display the data at the specified position.onCreateViewHolder(android.view.ViewGroup parent, int viewType) Called when the RecyclerView needs a newAdminBrowseEventsAdapter.EventViewHolderof the given type to represent an item.voidReplaces the full event list from LiveData, sorts newest first, then reapplies the current search filter.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
-
AdminBrowseEventsAdapter
public AdminBrowseEventsAdapter(List<Event> eventList, AdminBrowseEventsAdapter.OnEventClickListener listener, AdminBrowseEventsAdapter.OnEventDeleteListener deleteListener) Constructs a new AdminBrowseEventsAdapter.
-
-
Method Details
-
setEvents
Replaces the full event list from LiveData, sorts newest first, then reapplies the current search filter. Called by the fragment whenever the LiveData updates.- Parameters:
newEvents- The updated list of events.
-
filter
Filters the displayed list to events whose name or description contains the query. Reapplies automatically after every LiveData update viasetEvents(java.util.List<com.example.breeze_seas.Event>).- Parameters:
query- The search string (case-insensitive).
-
onCreateViewHolder
@NonNull public AdminBrowseEventsAdapter.EventViewHolder onCreateViewHolder(@NonNull android.view.ViewGroup parent, int viewType) Called when the RecyclerView needs a newAdminBrowseEventsAdapter.EventViewHolderof the given type to represent an item. Inflates the layout resource.- Specified by:
onCreateViewHolderin classandroidx.recyclerview.widget.RecyclerView.Adapter<AdminBrowseEventsAdapter.EventViewHolder>- Returns:
- A new EventViewHolder that holds a View of the given view type.
-
onBindViewHolder
public void onBindViewHolder(@NonNull AdminBrowseEventsAdapter.EventViewHolder holder, int position) Called by the RecyclerView to display the data at the specified position. This method updates the contents of theAdminBrowseEventsAdapter.EventViewHolderto reflect the item at the given position.- Specified by:
onBindViewHolderin classandroidx.recyclerview.widget.RecyclerView.Adapter<AdminBrowseEventsAdapter.EventViewHolder>
-
getItemCount
public int getItemCount()Returns the total number of items in the data set held by the adapter.- Specified by:
getItemCountin classandroidx.recyclerview.widget.RecyclerView.Adapter<AdminBrowseEventsAdapter.EventViewHolder>- Returns:
- Total number of items in adapter.
-