Package com.ayvytr.adapter

Types

SmartAdapter
Link copied to clipboard
open class SmartAdapter<T>(list: MutableList<T>, bind: SmartContainer<T>?) : RecyclerView.Adapter<SmartViewHolder<T>>

RecyclerView.Adapter的继承类,可以继承重写open方法,可以使用smart满足大多数需求.

SmartContainer
Link copied to clipboard
open class SmartContainer<T>(@LayoutRes layoutId: Int, viewType: Int, bind: View.(T, position: Int) -> Unit)

Container for SmartAdapter, include layoutId, viewType and bind, bind for init view.

SmartDiffCallback
Link copied to clipboard
open class SmartDiffCallback<T>

为外部提供的略简便的Diff Callback,从0.1.0较为繁琐的函数变量改为直接提供方法,注意:实际场景中,区分Item是不是相等是用id或者 其他能确定唯一性的字段来区分的,所以,一定要重写 areItemsTheSame;区分Item内容是不是相等需要判断每个字段是不是相等,所以 需要重写 areContentsTheSame;数据更新Item有闪烁,是因为全量刷新时,数据Bean更新了但是未重写areItemsTheSame, 或者重写了 但是返回null,请一定要注意这几点.

SmartViewHolder
Link copied to clipboard
class SmartViewHolder<T>(containerView: View, viewType: Int, smartContainer: SmartContainer<T>) : RecyclerView.ViewHolder

View holder for SmartAdapter

Functions

smart
Link copied to clipboard
fun <T> Context.smart(init: SmartAdapterBuilder<T>.() -> Unit): SmartAdapter<T>
fun <T> Fragment.smart(init: SmartAdapterBuilder<T>.() -> Unit): SmartAdapter<T>
fun <T> Context.smart(list: List<T>, @LayoutRes layoutId: Int, bind: View.(T, position: Int) -> Unit, init: SmartAdapterBuilder<T>.() -> Unit): SmartAdapter<T>
fun <T> Fragment.smart(list: List<T>, @LayoutRes layoutId: Int, bind: View.(T, position: Int) -> Unit, init: SmartAdapterBuilder<T>.() -> Unit): SmartAdapter<T>