package com.atmob.keyboard_android.component.item

import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import com.airbnb.lottie.LottieAnimationView
import com.atmob.keyboard_android.R
import com.atmob.keyboard_android.model.AiGenerateLoadingModel
import com.atmob.keyboard_android.util.LottieAnimationUtil
import me.drakeet.multitype.ItemViewBinder

/**
 * Ai生成内容的Loading中的列表项
 */
class AiGenerateLoadingViewBinder :
    ItemViewBinder<AiGenerateLoadingModel, AiGenerateLoadingViewBinder.InnerViewBinder>() {
    override fun onCreateViewHolder(
        inflater: LayoutInflater,
        parent: ViewGroup
    ): InnerViewBinder {
        return InnerViewBinder(
            inflater.inflate(
                R.layout.item_ai_generate_loading,
                parent,
                false
            )
        )
    }

    override fun onBindViewHolder(
        holder: InnerViewBinder,
        item: AiGenerateLoadingModel
    ) {
        LottieAnimationUtil.playLottieAnimation(
            holder.vLoadingLottieView,
            "lottie/anim_loading.json"
        )
    }

    inner class InnerViewBinder(itemView: View) : RecyclerView.ViewHolder(itemView) {
        var vLoadingLottieView: LottieAnimationView =
            itemView.findViewById(R.id.loading_lottie_view)
    }
}