package com.audio.record.screen.test.adapter

import android.content.Context
import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import com.audio.record.screen.test.base.BaseAdapter
import com.audio.record.screen.test.data.VideoGroup
import com.audio.record.screen.test.databinding.AdapterVideoDateBinding
import com.audio.record.screen.test.tool.Common
import com.audio.record.screen.test.tool.NoScrollLinearLayoutManager

class VideoGroupAdapter(context: Context, private var click: (cropRatio: String) -> Unit) :
    BaseAdapter<VideoGroup, AdapterVideoDateBinding>(context) {
    override fun getViewBinding(parent: ViewGroup?): AdapterVideoDateBinding {
        return AdapterVideoDateBinding.inflate(LayoutInflater.from(parent!!.context), parent, false)
    }

    override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
        val itemHolder: VHolder<AdapterVideoDateBinding> =
            holder as VHolder<AdapterVideoDateBinding>

        val item = data[position]
        itemHolder.vb.run {

            tvDate.text = item.date

            videoInfoRecycler.run {
                setHasFixedSize(false)
                adapter = VideoInfoAdapter(mContext, position == data.size - 1) {}.apply {
                    updateData(item.videos)
                }
                layoutManager = NoScrollLinearLayoutManager(mContext)
                isNestedScrollingEnabled = false
            }
        }


    }

}