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.MedicalBean

class MedicalHistoryAdapter : BaseAdapter<MedicalBean>(R.layout.item_medical_history) {
    override fun convert(holder: BaseViewHolder, item: MedicalBean) {

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

        initAdapter(holder.getView(R.id.mRecycle),item.durg)
    }
    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>)


    }
}