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

import android.annotation.SuppressLint
import android.content.Context
import android.view.LayoutInflater
import android.view.ViewGroup
import android.widget.ImageView
import com.bumptech.glide.Glide
import com.bumptech.glide.load.resource.bitmap.CenterCrop
import com.bumptech.glide.load.resource.bitmap.RoundedCorners
import com.bumptech.glide.request.RequestOptions
import com.ux.video.file.filerecovery.R
import com.ux.video.file.filerecovery.base.BaseAdapter
import com.ux.video.file.filerecovery.databinding.ScanResultAdapterBinding
import com.ux.video.file.filerecovery.databinding.ScanResultDocumentsAdapterBinding
import com.ux.video.file.filerecovery.photo.ResultPhotos
import com.ux.video.file.filerecovery.photo.ResultPhotosFiles
import com.ux.video.file.filerecovery.utils.Common
import com.ux.video.file.filerecovery.utils.ExtendFunctions.dpToPx
import java.io.File

/**
 * 文件或者音频的扫描结果汇总适配器
 */
class ScanResultDocumentsAdapter(
    mContext: Context,
    var type: Int,
    var onClickItem: (allFiles: ArrayList<ResultPhotosFiles>) -> Unit
) :
    BaseAdapter<ResultPhotos, 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: ResultPhotos
    ) {

        holder.vb.run {
            item.run {
                relativeLayout.setOnClickListener { onClickItem(allFiles) }
                textDirName.text = dirName
                textFileCounts.text = allFiles.size.toString()
                when(type){
                    Common.VALUE_SCAN_TYPE_audio, Common.VALUE_SCAN_TYPE_deleted_audio->{
                       icon.setImageResource(R.drawable.icon_folder_audio)
                    }
                    Common.VALUE_SCAN_TYPE_documents, Common.VALUE_SCAN_TYPE_deleted_documents->{
                        icon.setImageResource(R.drawable.icon_folder_documents)
                    }
                }

            }
        }


    }


}