BaseAdapter

open class BaseAdapter<T : Any> @JvmOverloads constructor(var mContext: Context, factories: MutableList<ItemHolder.HolderFactory<T>>, val mItemList: MutableList<ItemWrapper<T>> = mutableListOf()) : RecyclerView.Adapter<ItemHolder<T>> , ItemClickListener<T>

BaseAdapter

Since

1.2.0

Constructors

Link copied to clipboard
constructor(mContext: Context, factories: MutableList<ItemHolder.HolderFactory<T>>, mItemList: MutableList<ItemWrapper<T>> = mutableListOf())

Properties

Link copied to clipboard
val data: List<T>

Only used to get the data of the element in the current list.

Link copied to clipboard
protected var mContext: Context
Link copied to clipboard
private var mEmptyItem: ItemWrapper<T>?
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Functions

Link copied to clipboard
fun add(item: ItemWrapper<T>, position: Int = itemCount)

Adds item to the position specified by position.

fun add(items: List<ItemWrapper<T>>, position: Int = itemCount)

Adds items to the position specified by position.

fun add(item: T, @LayoutRes layout: Int, position: Int = itemCount, scope: ItemWrapper<T>.() -> Unit = {})

Adds item to the position specified by position, with the layout being layout.

fun add(items: List<T>, @LayoutRes layout: Int, position: Int = itemCount, scope: ItemWrapper<T>.() -> Unit = {})

Adds items to the position specified by position, with the layout being layout.

Link copied to clipboard
fun clear()

Removes all elements from mItemList.。

Link copied to clipboard
override fun getItemCount(): Int
Link copied to clipboard
override fun getItemViewType(position: Int): Int
Link copied to clipboard
Link copied to clipboard
private fun isEmpty(): Boolean

mItemList will be judged to be empty when it is in the following two situations:

Link copied to clipboard
override fun onBindViewHolder(holder: ItemHolder<T>, position: Int)
Link copied to clipboard
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ItemHolder<T>
Link copied to clipboard
fun removeAt(position: Int): T?

Removes item at the specified position from the mItemList.

Link copied to clipboard
fun setEmptyView(@LayoutRes id: Int?, scope: ItemWrapper<T>.() -> Unit = {})

Custom empty layout. Specify the layout through id and specify the click event related to the layout through scope.

Link copied to clipboard
override fun setOnItemClickListener(listener: OnItemClickListener<T>?)

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

Link copied to clipboard

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

Link copied to clipboard
fun update(item: ItemWrapper<T>, position: Int): Boolean
fun update(item: T, @LayoutRes layout: Int, position: Int, scope: ItemWrapper<T>.() -> Unit = {}): Boolean

Updates item at the specified position from the mItemList.