Package com.example.qrgo.utilities
Class StaggeredAdapter
- java.lang.Object
-
- androidx.recyclerview.widget.RecyclerView.Adapter<StaggeredAdapter.ViewHolder>
-
- com.example.qrgo.utilities.StaggeredAdapter
-
public class StaggeredAdapter extends androidx.recyclerview.widget.RecyclerView.Adapter<StaggeredAdapter.ViewHolder>
The StaggeredAdapter class is an implementation of the RecyclerView.Adapter that supports the display of images in a staggered grid layout.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classStaggeredAdapter.ViewHolderThe ViewHolder class holds references to the views that make up the item view.
-
Constructor Summary
Constructors Constructor Description StaggeredAdapter(java.util.List<java.lang.String> data, android.content.Context context)Constructs a new StaggeredAdapter with the specified list of data and context.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intgetItemCount()Returns the total number of items in the data list.voidonBindViewHolder(StaggeredAdapter.ViewHolder holder, int position)Called when a ViewHolder is bound to a new item.StaggeredAdapter.ViewHolderonCreateViewHolder(android.view.ViewGroup parent, int viewType)Called when a new ViewHolder is created.-
Methods inherited from class androidx.recyclerview.widget.RecyclerView.Adapter
bindViewHolder, createViewHolder, getItemId, getItemViewType, hasObservers, hasStableIds, notifyDataSetChanged, notifyItemChanged, notifyItemChanged, notifyItemInserted, notifyItemMoved, notifyItemRangeChanged, notifyItemRangeChanged, notifyItemRangeInserted, notifyItemRangeRemoved, notifyItemRemoved, onAttachedToRecyclerView, onBindViewHolder, onDetachedFromRecyclerView, onFailedToRecycleView, onViewAttachedToWindow, onViewDetachedFromWindow, onViewRecycled, registerAdapterDataObserver, setHasStableIds, unregisterAdapterDataObserver
-
-
-
-
Constructor Detail
-
StaggeredAdapter
public StaggeredAdapter(java.util.List<java.lang.String> data, android.content.Context context)Constructs a new StaggeredAdapter with the specified list of data and context.- Parameters:
data- The list of data to display.context- The context used to inflate the layout.
-
-
Method Detail
-
onCreateViewHolder
@NonNull public StaggeredAdapter.ViewHolder onCreateViewHolder(@NonNull android.view.ViewGroup parent, int viewType)
Called when a new ViewHolder is created.- Specified by:
onCreateViewHolderin classandroidx.recyclerview.widget.RecyclerView.Adapter<StaggeredAdapter.ViewHolder>- Parameters:
parent- The ViewGroup into which the new View will be added.viewType- The view type of the new View.- Returns:
- A new ViewHolder that holds a View of the given view type.
-
onBindViewHolder
public void onBindViewHolder(@NonNull StaggeredAdapter.ViewHolder holder, int position)Called when a ViewHolder is bound to a new item.- Specified by:
onBindViewHolderin classandroidx.recyclerview.widget.RecyclerView.Adapter<StaggeredAdapter.ViewHolder>- Parameters:
holder- The ViewHolder to bind the data to.position- The position of the item in the data list.
-
getItemCount
public int getItemCount()
Returns the total number of items in the data list.- Specified by:
getItemCountin classandroidx.recyclerview.widget.RecyclerView.Adapter<StaggeredAdapter.ViewHolder>- Returns:
- The total number of items in the data list.
-
-