package com.zj365.mime.adapter

import android.widget.EditText
import com.chad.library.adapter.base.BaseMultiItemQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.zj365.mime.R
import com.xty.network.model.SportDetail


class DetailChildAdapter: BaseMultiItemQuickAdapter<SportDetail.Action.Group, BaseViewHolder>()  {

    private val index= listOf("一","二","三","四","五","六","七","八","九","十","十一","十二","十三","十四"
        ,"十五","十六","十七","十八","十九","二十","二十一","二十二","二十三","二十四","二十五","二十六","二十七","二十八","二十九","三十")


    var mapView= mutableMapOf<Int,MutableList<EditText>>()
    init {
        mapView.clear()
        addItemType(1, R.layout.item_detail_child_1)
        addItemType(2, R.layout.item_detail_child_2)
        addItemType(3, R.layout.item_detail_child_3)
        addItemType(4, R.layout.item_detail_child_3)
    }
    override fun convert(holder: BaseViewHolder, item: SportDetail.Action.Group) {
        holder.setText(R.id.v0,"第${index[holder.layoutPosition]}组　")
        when(item.itemType){
            1->{
                holder.setText(R.id.v1,item.dataValue1?:"")
                    .setText(R.id.v2,item.dataValue2?:"")
            }
            2->{
                holder  .setText(R.id.v1,item.dataValue1?:"")
                    .setText(R.id.mV11,item.dataValue2?:"")
                var v2=holder.getView<EditText>(R.id.v2)
                var v22=holder.getView<EditText>(R.id.mV22)
                var list= mutableListOf(v2,v22)
                mapView[holder.layoutPosition]=list
            }
            3,4->{
                holder  .setText(R.id.v1,item.dataValue1?:"")
                    .setText(R.id.mV11,item.dataValue2?:"")
                    .setText(R.id.v2,item.realDataValue1?:"")
                    .setText(R.id.mV22,item.realDataValue2?:"")
            }

        }

    }
}