package com.hongyegroup.cpt_pensonal.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_pensonal.BR
import com.hongyegroup.cpt_pensonal.R
import com.hongyegroup.cpt_pensonal.databinding.ActivityPensonalAppointmentTestListBinding
import com.hongyegroup.cpt_pensonal.mvvm.PensonalMyTestViewModel

/**
 * 个人用户 我的预约列表
 */
class PensonalAppointmentTestListActivity : YYBaseVDBActivity<PensonalMyTestViewModel, ActivityPensonalAppointmentTestListBinding>() {

    private val mClickProxy by lazy { ClickProxy() }

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

    override fun getDataBindingConfig(): DataBindingConfig {
        return DataBindingConfig(R.layout.activity_pensonal_appointment_test_list, BR.viewModel, mViewModel)
            .addBindingParams(BR.click, mClickProxy)
    }

    override fun startObserve() {

    }

    override fun init(savedInstanceState: Bundle?) {

        initRV()
        initData()
    }

    private fun initData() {

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

        mViewModel.mAdapter.notifyDataSetChanged()

    }

    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 = ""
        }


    }

}