package com.hongyegroup.cpt_business.ui.activity

import android.content.Intent
import android.os.Bundle
import com.guadou.cs_cptservices.base.activity.YYBaseVDBActivity
import com.guadou.lib_baselib.bean.DataBindingConfig
import com.guadou.lib_baselib.ext.toast
import com.guadou.lib_baselib.ext.vertical
import com.guadou.lib_baselib.utils.CommUtils
import com.guadou.lib_baselib.utils.KeyboardUtils
import com.hongyegroup.cpt_business.BR
import com.hongyegroup.cpt_business.R
import com.hongyegroup.cpt_business.databinding.ActivityBusinessAppointmentDateBinding
import com.hongyegroup.cpt_business.mvvm.vm.BusinessAppointmentDateViewModel

/**
 * 公司预约列表
 * 指定日期下面全部的员工的预约列表
 */
class BusinessAppointmentDateActivity : YYBaseVDBActivity<BusinessAppointmentDateViewModel, ActivityBusinessAppointmentDateBinding>() {

    companion object {
        fun startInstance() {
            val context = CommUtils.getContext()
            val intent = Intent(context, BusinessAppointmentDateActivity::class.java)
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
            context.startActivity(intent)
        }
    }

    override fun getDataBindingConfig(): DataBindingConfig {
        return DataBindingConfig(R.layout.activity_business_appointment_date)
            .addBindingParams(BR.click, ClickProxy())
    }

    override fun startObserve() {

    }

    override fun init(savedInstanceState: Bundle?) {

        initRV()
        initData()
        initListener()
    }

    private fun initData() {

        for (i in 1..10) {
            mViewModel.mDatas.add(i.toString())
        }

        mViewModel.mAdapter.notifyDataSetChanged()

    }

    private fun initListener() {

    }

    private fun initRV() {

        mBinding.recyclerView.vertical().adapter = mViewModel.mAdapter

    }

    /**
     * DataBinding事件处理
     */
    inner class ClickProxy {

        //执行搜索
        fun doSearch() {
            KeyboardUtils.hideSoftInput(mActivity)

            val searchText = mViewModel.mKeywordLiveData.value

            toast("Search:$searchText")

        }

        //搜索的删除
        fun searchDel() {
            mViewModel.mKeywordLiveData.value = ""
        }

    }

}