Class BaseRecyclerViewAdapter

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Field Summary

      Fields 
      Modifier and Type Field Description
      public final static String TAG
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      BaseRecyclerViewHolder<T> onCreateViewHolder(ViewGroup parent, Integer viewType)
      Unit onBindViewHolder(BaseRecyclerViewHolder<T> viewHolder, Integer position)
      Integer getItemCount()
      final ArrayList<T> getItems() Returns the items in the data set held by this adapter.
      final List<T> getItems(Function1<T, Boolean> predicate) Returns the items that are filtered by class in the data set held by this adapter.
      Unit setItems(List<T> items) Sets new items to display in this adapter.
      final Unit addItems(List<T> items) Add new items to display in this adapter.
      final Unit clearItems() Clear all items in this adapter.
      final T getItem(Integer position) Returns the item at the specified position in this adapter.
      final T first() Returns the non null first item in this adapter.
      final T firstOrNull() Returns the first item (null or not) in this adapter.
      final Unit addItem(T item, Integer position) Add a new item to display in this adapter.
      final Unit updateItem(T item) Update an item to display in this adapter.
      final Unit updateItem(T item, Integer position) Update the item at position in this adapter.
      final Unit removeItem(Integer position) Remove the item at position from this adapter.
      final Unit removeItem(T item) Remove an item displaying in this adapter.
      final Integer indexOf(T item)
      final Boolean isEmpty() Returns true if the items in this adapter is empty.
      final Unit setItemClickListener(Function1<T, Unit> onItemClick) Register a callback to be invoked when an item is clicked.
      final Unit setItemLongClickListener(Function1<T, Unit> onItemLongClick) Register a callback to be invoked when an item is clicked and held.
      • 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

      • BaseRecyclerViewAdapter

        BaseRecyclerViewAdapter(List<T> items, Function1<T, Unit> onItemClick, Function1<T, Unit> onItemLongClick, DiffCallback<T> diffCallback)
    • Method Detail

      • getItems

         final ArrayList<T> getItems()

        Returns the items in the data set held by this adapter.

        Returns:

        The items in this adapter.

      • getItems

         final List<T> getItems(Function1<T, Boolean> predicate)

        Returns the items that are filtered by class in the data set held by this adapter.

        Returns:

        The items by type.

      • setItems

         Unit setItems(List<T> items)

        Sets new items to display in this adapter.

        Parameters:
        items - The items to display in this adapter.
      • addItems

         final Unit addItems(List<T> items)

        Add new items to display in this adapter.

        Parameters:
        items - The items to display in this adapter.
      • getItem

         final T getItem(Integer position)

        Returns the item at the specified position in this adapter.

        Parameters:
        position - position of the item to return
        Returns:

        the item at the specified position in this adapter

      • first

         final T first()

        Returns the non null first item in this adapter.

        Returns:

        the non null first item in this adapter

      • firstOrNull

         final T firstOrNull()

        Returns the first item (null or not) in this adapter.

        Returns:

        the first item (null or not) in this adapter

      • addItem

         final Unit addItem(T item, Integer position)

        Add a new item to display in this adapter.

        Parameters:
        item - The item to add.
      • updateItem

         final Unit updateItem(T item)

        Update an item to display in this adapter.

        Parameters:
        item - The item to be updated.
      • updateItem

         final Unit updateItem(T item, Integer position)

        Update the item at position in this adapter.

        Parameters:
        item - The item to be updated.
        position - Position of the item to be updated
      • removeItem

         final Unit removeItem(Integer position)

        Remove the item at position from this adapter.

        Parameters:
        position - The position at which the item to remove.
      • removeItem

         final Unit removeItem(T item)

        Remove an item displaying in this adapter.

        Parameters:
        item - The item to remove.
      • isEmpty

         final Boolean isEmpty()

        Returns true if the items in this adapter is empty.

        Returns:

        true if the items in this adapter is empty.

      • setItemClickListener

         final Unit setItemClickListener(Function1<T, Unit> onItemClick)

        Register a callback to be invoked when an item is clicked.

        Parameters:
        onItemClick - callback
      • setItemLongClickListener

         final Unit setItemLongClickListener(Function1<T, Unit> onItemLongClick)

        Register a callback to be invoked when an item is clicked and held.

        Parameters:
        onItemLongClick - callback