package com.ux.video.file.filerecovery.result

import android.annotation.SuppressLint
import android.content.Context
import android.view.LayoutInflater
import android.view.ViewGroup
import com.ux.video.file.filerecovery.R
import com.ux.video.file.filerecovery.base.BaseAdapter
import com.ux.video.file.filerecovery.databinding.ScanResultDocumentsAdapterBinding
import com.ux.video.file.filerecovery.db.ResultData
import com.ux.video.file.filerecovery.db.ResultDataFiles
import com.ux.video.file.filerecovery.utils.Common
import com.ux.video.file.filerecovery.utils.FileType

/**
 * 文件或者音频的扫描结果汇总适配器
 */
class ScanResultDocumentsAudioAdapter(
    mContext: Context,
    var fileType: FileType,
    var onClickItem: (allFiles: ArrayList<ResultDataFiles>) -> Unit
) :
    BaseAdapter<ResultData, ScanResultDocumentsAdapterBinding>(mContext) {
    override fun getViewBinding(parent: ViewGroup): ScanResultDocumentsAdapterBinding =
        ScanResultDocumentsAdapterBinding.inflate(
            LayoutInflater.from(parent.context),
            parent,
            false
        )

    @SuppressLint("SetTextI18n")
    override fun bindItem(
        holder: VHolder<ScanResultDocumentsAdapterBinding>,
        item: ResultData
    ) {

        holder.vb.run {
            item.run {
                relativeLayout.setOnClickListener { onClickItem(allFiles) }
                textDirName.text = dirName
                textFileCounts.text = allFiles.size.toString()
                when(fileType){
                    FileType.AUDIO ->{
                       icon.setImageResource(R.drawable.icon_folder_audio)
                    }
                    FileType.DOCUMENT->{
                        icon.setImageResource(R.drawable.icon_folder_documents)
                    }

                    else -> Unit
                }

            }
        }


    }


}