Class DynamicRecyclerViewBinder<VH extends RecyclerView.ViewHolder>

java.lang.Object
com.pranavpandey.android.dynamic.support.recyclerview.binder.DynamicRecyclerViewBinder<VH>
Type Parameters:
VH - The type of the dynamic recycler view binder.
Direct Known Subclasses:
DynamicDataBinder

public abstract class DynamicRecyclerViewBinder<VH extends RecyclerView.ViewHolder> extends Object
A data binder class to bind data with the view inside the DynamicBinderAdapter.

Extend this class to implement your own data binding logic.

  • Constructor Details

    • DynamicRecyclerViewBinder

      public DynamicRecyclerViewBinder(@NonNull DynamicBinderAdapter binderAdapter)
      Constructor to initialize an object of this class.
      Parameters:
      binderAdapter - The dynamic binder adapter for the recycler view.
  • Method Details

    • onCreateViewHolder

      @NonNull public abstract VH onCreateViewHolder(@NonNull ViewGroup parent, int viewType)
      Get the RecyclerView.ViewHolder for this data binder.
      Parameters:
      parent - The parent for this view holder.
      viewType - The type of the view to create the view holder.
      Returns:
      The view holder associated with this data binder.
    • onBindViewHolder

      public abstract void onBindViewHolder(@NonNull VH holder, int position)
      Bind RecyclerView.ViewHolder at a particular position.
      Parameters:
      holder - The view holder for the recycler view.
      position - The position to bind the view holder.
    • getRecyclerViewAdapter

      @Nullable public RecyclerView.Adapter<RecyclerView.ViewHolder> getRecyclerViewAdapter()
      Get the recycler view adapter associated with this data binder.
      Returns:
      The recycler view adapter associated with this data binder.
    • getBinderAdapter

      @NonNull public DynamicBinderAdapter getBinderAdapter()
      Get the recycler view adapter associated with this data binder.
      Returns:
      The recycler view adapter associated with this data binder.
    • getItemCount

      public abstract int getItemCount()
      Returns the total no. of items in this data binder.
      Returns:
      The total no. of items in this data binder.
    • notifyDataSetChanged

      public final void notifyDataSetChanged()
      Notify adapter when the data has been changed.
    • notifyBinderItemChanged

      public final void notifyBinderItemChanged(int position)
      Notify adapter when an item has been changed in this data binder.
      Parameters:
      position - The position at which the item has been changed.
    • notifyBinderDataSetChanged

      public final void notifyBinderDataSetChanged()
      Notify adapter when the data has been changed in this data binder.
    • notifyBinderItemInserted

      public final void notifyBinderItemInserted(int position)
      Notify adapter when an item has been inserted in this data binder.
      Parameters:
      position - The position at which the item has been inserted.
    • notifyBinderItemMoved

      public final void notifyBinderItemMoved(int fromPosition, int toPosition)
      Notify adapter when an item has been moved in this data binder.
      Parameters:
      fromPosition - Initial position of the moved item.
      toPosition - Final position of the moved item.
    • notifyBinderItemRemoved

      public final void notifyBinderItemRemoved(int position)
      Notify adapter when an item has been removed in this data binder.
      Parameters:
      position - The position at which the item has been removed.
    • notifyBinderItemRangeChanged

      public final void notifyBinderItemRangeChanged(int position, int itemCount)
      Notify adapter when the item range of this data binder has been changed.
      Parameters:
      position - The position at which the first item has been changed.
      itemCount - Total no. of items have been changed.
    • notifyBinderItemRangeInserted

      public final void notifyBinderItemRangeInserted(int position, int itemCount)
      Notify adapter when a set of items have been inserted in this data binder.
      Parameters:
      position - The position at which the first item has been inserted.
      itemCount - Total no. of items have been inserted.
    • notifyBinderItemRangeRemoved

      public final void notifyBinderItemRangeRemoved(int position, int itemCount)
      Notify adapter when a set of items have been removed in this data binder.
      Parameters:
      position - The position at which the first item has been removed.
      itemCount - Total no. of items have been removed.