package com.medicdigital.jjpodcasts.presentation.podcasts.adapter

import android.view.View
import com.bumptech.glide.Glide
import com.bumptech.glide.request.RequestOptions
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.medicdigital.jjpodcasts.R
import com.medicdigital.jjpodcasts.data.remote.responce.NodeItem
import com.medicdigital.jjpodcasts.presentation.extentions.getRoundedOutlineProvider
import com.medicdigital.jjpodcasts.presentation.podcasts.EpisodesClick
import com.medicdigital.jjpodcasts.presentation.utils.Constants
import com.medicdigital.jjpodcasts.presentation.utils.getNodeFeatureImage
import com.medicdigital.jjpodcasts.presentation.utils.getNodeImage
import com.medicdigital.jjpodcasts.presentation.utils.getTypeWithPriorityEx
import com.medicdigital.jjpodcasts.presentation.podcasts.adapter.databinding.ItemPodcastFeaturedBinding


class PodcastFeaturedListAdapter(private val itemClickListener: EpisodesClick?, private val itemWidth: Int, private val itemHeight: Int) :
       BaseQuickAdapter<NodeItem, BaseViewHolder>(R.layout.item_podcast_featured),
       View.OnClickListener {

    override fun convert(holder: BaseViewHolder, item: NodeItem) {
       val itemView = holder.itemView

       val ivPodcastFeatured = itemView.iv_podcast_featured_logo
       ivPodcastFeatured.layoutParams.height = itemHeight
       Glide.with(context)
             .load(getNodeFeatureImage(item?.assets ?: arrayListOf()) ?: getNodeImage(item?.assets ?: arrayListOf()))
             .placeholder(R.drawable.ic_microfon_gray)
             .apply(RequestOptions.fitCenterTransform())
             .into(ivPodcastFeatured)

       itemView.txt_podcast_featured.text = item?.name

       itemView.vg_podcast_featured_logo.apply {
          tag = item
          setOnClickListener(this@PodcastFeaturedListAdapter)
          outlineProvider = context.getRoundedOutlineProvider(alpha = .3f, cornerRadius = R.dimen.corner_4)
       }
    }

    override fun onClick(v: View?) {
       v ?: return
       val nodeItem = v.tag as? NodeItem?
       when (v.id) {
          R.id.vg_podcast_featured_logo -> {
             if (nodeItem?.type == Constants.TYPE_PODCAST_EPISODE.toString()) {
                when (getTypeWithPriorityEx(nodeItem, nodeItem.url, nodeItem.quiz)) {
                   Constants.TYPE_VIDEO -> {
                      itemClickListener?.onEpisodeClick(nodeItem, getTypeWithPriorityEx(nodeItem, nodeItem.url, nodeItem.quiz))
                   }
                   Constants.TYPE_AUDIO -> {
                      itemClickListener?.onEpisodeClick(nodeItem, getTypeWithPriorityEx(nodeItem, nodeItem.url, nodeItem.quiz))
                   }
                   Constants.TYPE_PDF -> {
                      itemClickListener?.onEpisodeClick(nodeItem, getTypeWithPriorityEx(nodeItem, nodeItem.url, nodeItem.quiz))
                   }
                   Constants.TYPE_GALLERY -> {
                      itemClickListener?.onEpisodeClick(nodeItem, getTypeWithPriorityEx(nodeItem, nodeItem.url, nodeItem.quiz))
                   }
                   Constants.EXTERNAL_LINK -> {
                      itemClickListener?.onEpisodeClick(nodeItem, getTypeWithPriorityEx(nodeItem, nodeItem.url, nodeItem.quiz))
                   }
                   Constants.QUIZ -> {
                      itemClickListener?.onEpisodeClick(nodeItem, getTypeWithPriorityEx(nodeItem, nodeItem.url, nodeItem.quiz))
                   }
                }
             } else {
                itemClickListener?.onNodeWithDetailInfoClick(nodeItem)
             }
          }
       }
    }
} for this file we are expecting these errors e: file:///home/sourav/Downloads/AIMeCAST-andriodapp-a8bbcfd55c39/app/src/main/java/com/medicdigital/jjpodcasts/presentation/podcasts/adapter/PodcastFeaturedListAdapter.kt:16:66 Unresolved reference: databinding
e: file:///home/sourav/Downloads/AIMeCAST-andriodapp-a8bbcfd55c39/app/src/main/java/com/medicdigital/jjpodcasts/presentation/podcasts/adapter/PodcastFeaturedListAdapter.kt:26:36 Unresolved reference: iv_podcast_featured_logo
e: file:///home/sourav/Downloads/AIMeCAST-andriodapp-a8bbcfd55c39/app/src/main/java/com/medicdigital/jjpodcasts/presentation/podcasts/adapter/PodcastFeaturedListAdapter.kt:27:34 Variable expected
e: file:///home/sourav/Downloads/AIMeCAST-andriodapp-a8bbcfd55c39/app/src/main/java/com/medicdigital/jjpodcasts/presentation/podcasts/adapter/PodcastFeaturedListAdapter.kt:34:12 Unresolved reference: txt_podcast_featured
e: file:///home/sourav/Downloads/AIMeCAST-andriodapp-a8bbcfd55c39/app/src/main/java/com/medicdigital/jjpodcasts/presentation/podcasts/adapter/PodcastFeaturedListAdapter.kt:34:33 Variable expected
e: file:///home/sourav/Downloads/AIMeCAST-andriodapp-a8bbcfd55c39/app/src/main/java/com/medicdigital/jjpodcasts/presentation/podcasts/adapter/PodcastFeaturedListAdapter.kt:36:12 Unresolved reference: vg_podcast_featured_logo
e: file:///home/sourav/Downloads/AIMeCAST-andriodapp-a8bbcfd55c39/app/src/main/java/com/medicdigital/jjpodcasts/presentation/podcasts/adapter/PodcastFeaturedListAdapter.kt:37:4 Unresolved reference: tag
e: file:///home/sourav/Downloads/AIMeCAST-andriodapp-a8bbcfd55c39/app/src/main/java/com/medicdigital/jjpodcasts/presentation/podcasts/adapter/PodcastFeaturedListAdapter.kt:38:4 Unresolved reference: setOnClickListener
e: file:///home/sourav/Downloads/AIMeCAST-andriodapp-a8bbcfd55c39/app/src/main/java/com/medicdigital/jjpodcasts/presentation/podcasts/adapter/PodcastFeaturedListAdapter.kt:39:4 Unresolved reference: outlineProvider
 
can you rewrite the entire code so that viewbinding is used and no unnecsary changes are broiught about