package com.zj365.health.adapter

import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.xty.base.adapter.BaseAdapter
import com.xty.common.picture.PictureUtils
import com.xty.common.recycleUtils.RecycleItem
import com.zj365.health.BuildConfig
import com.zj365.health.R
import com.xty.network.model.EleTestBean

class ElectronicListAdapter:BaseAdapter<EleTestBean>(R.layout.item_ele_test) {
    override fun convert(holder: BaseViewHolder, item: EleTestBean) {


        holder.setText(R.id.mTime,if(item.time==null) "" else item.time)

        initAdapter(holder.getView(R.id.mRecycle1),item.urine)
        initAdapter(holder.getView(R.id.mRecycle2),item.kidney)
        initAdapter(holder.getView(R.id.mRecycle3),item.electrolyte)
        initAdapter(holder.getView(R.id.mRecycle4),item.cardiac)
        initAdapter(holder.getView(R.id.mRecycle5),item.tumor)
        initAdapter(holder.getView(R.id.mRecycle6),item.other)
    }



    private fun initAdapter(recycle: RecyclerView,list:MutableList<String>){
        var  mAdapter= ImageAdapter(true)
        var item= RecycleItem(context,5,1)
        item.setSpace(10,10)
        recycle.adapter=mAdapter
        recycle.addItemDecoration(item)
        recycle.layoutManager= GridLayoutManager(context,5)
        recycle.tag=mAdapter
        mAdapter.setOnItemClickListener { adapter, view, position ->
            PictureUtils.httpPreviewImage(context,position,adapter.data as MutableList<String>,BuildConfig.image_prefix)
        }
        mAdapter.setNewInstance(list as MutableList<Any>)


    }
}