package com.wdkl.ncs.android.component.hello.adapter

import android.util.Log
import android.view.View
import android.view.ViewGroup
import com.alibaba.android.vlayout.LayoutHelper
import com.alibaba.android.vlayout.layout.LinearLayoutHelper
import com.wdkl.ncs.android.component.hello.R
import com.wdkl.ncs.android.component.hello.databinding.HelloListItemLayBinding
import com.wdkl.ncs.android.lib.adapter.BaseDelegateAdapter
import com.wdkl.ncs.android.lib.utils.BaseRecyclerViewHolder
import com.wdkl.ncs.android.middleware.model.JavaShopItem
import com.wdkl.ncs.android.middleware.model.ShopItem
import kotlinx.android.synthetic.main.hello_list_item_lay.view.*

class HelloItemAdapter(val data:ArrayList<JavaShopItem>) : BaseDelegateAdapter<BaseRecyclerViewHolder<HelloListItemLayBinding>,JavaShopItem>(){
    override fun dataProvider(): Any {
        return data
    }

    override fun itemFilter(position: Int): Boolean {
        return true
    }

    override fun getItemCount(): Int {
        return data.size
    }

    override fun onCreateLayoutHelper(): LayoutHelper {
        Log.i("abc",data.toString());
        return LinearLayoutHelper(0,data.size)
    }

    override fun onCreateViewHolder(parent: ViewGroup?, viewType: Int): BaseRecyclerViewHolder<HelloListItemLayBinding> {
        return BaseRecyclerViewHolder.build(parent, R.layout.hello_list_item_lay)
    }

    override fun onBindViewHolder(holder: BaseRecyclerViewHolder<HelloListItemLayBinding>?, position: Int) {
        holder?.bind {
            binding ->
            val itemData = getItem(position)
            binding.helloListItemTv.text = itemData.shopName
        }
    }
}