Class 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 class  StaggeredAdapter.ViewHolder
      The 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
      int getItemCount()
      Returns the total number of items in the data list.
      void onBindViewHolder​(StaggeredAdapter.ViewHolder holder, int position)
      Called when a ViewHolder is bound to a new item.
      StaggeredAdapter.ViewHolder onCreateViewHolder​(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
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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:
        onCreateViewHolder in class androidx.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:
        onBindViewHolder in class androidx.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:
        getItemCount in class androidx.recyclerview.widget.RecyclerView.Adapter<StaggeredAdapter.ViewHolder>
        Returns:
        The total number of items in the data list.