package com.adealink.frame.imkit.widget.adapter

import android.view.ViewGroup

interface IViewProvider<T> {
    fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder

    /**
     * @param item 数据
     * @return 是否是模板类型
     */
    fun isItemViewType(item: T): Boolean

    /**
     * 根据数据源绑定视图
     *
     * @param holder 视图
     * @param t 数据
     * @param position 位置
     */
    fun bindViewHolder(
        holder: ViewHolder,
        t: T,
        position: Int,
        list: List<T>,
        listener: IViewProviderListener<T>?
    )

    fun onViewAttachedToWindow(holder: ViewHolder) {}

    fun onViewDetachedFromWindow(holder: ViewHolder) {
        holder.clear()
    }

    fun onViewRecycled(holder: ViewHolder) {
        holder.clear()
    }
}
