package com.yidianling.home.ui.view

import android.content.Context
import android.view.LayoutInflater
import android.view.ViewGroup
import android.widget.LinearLayout
import androidx.databinding.DataBindingUtil
import androidx.recyclerview.widget.RecyclerView
import com.yidianling.home.R
import com.yidianling.home.databinding.HomeButtonBannerViewBinding
import com.yidianling.home.event.IHomeBaseEvent
import com.yidianling.home.model.bean.HomeHeaderBean

/**
 * @author <a href="https://www.jianshu.com/u/c1e5310dd724">xujian</a>
 * @描述: 顶部预约专家，即时倾诉，心理课堂，心理测试按钮模块
 * @Copyright Copyright (c) 2019
 * @Company 壹点灵
 * @date 2019/02/13
 */
class HomeButtonBannerView(private val mContext: Context, private var homeEvent: IHomeBaseEvent?) :
    LinearLayout(mContext) {
    private var dataBinding: HomeButtonBannerViewBinding? = null

    init {
        initView()
    }

    private fun initView() {
        val params = RecyclerView.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.WRAP_CONTENT
        )
        layoutParams = params
        dataBinding = DataBindingUtil.inflate(
            LayoutInflater.from(mContext),
            R.layout.home_button_banner_view,
            this,
            true
        )

        dataBinding?.homeModuleButtonBannerFirst?.setOnClickListener {
            homeEvent?.reservationExpertsClick()
        }
        dataBinding?.homeModuleButtonBannerSecond?.setOnClickListener {
            homeEvent?.nowConfideClick(false)
        }
        dataBinding?.homeModuleButtonBannerThird?.setOnClickListener {
            homeEvent?.psychologyClassClick()
        }
        dataBinding?.homeModuleButtonBannerFourth?.setOnClickListener {
            homeEvent?.psychologyTestClick()
        }
        dataBinding?.loopAvatar?.stopLoop()
        dataBinding?.loopAvatar?.startLoop()
    }


    fun initData(
        homeCategory: List<HomeHeaderBean.CategoryGoldListDataBean>?
    ) {
        homeEvent?.let { dataBinding?.homeCategoryView?.setEvent(it) }
        dataBinding?.homeCategoryView?.initData(homeCategory)

    }


}