package com.hongyegroup.cpt_rewards.ui.fragment

import android.os.Bundle
import android.view.View
import androidx.databinding.ViewDataBinding
import com.guadou.lib_baselib.base.fragment.BaseVDBLazyLoadingFragment
import com.guadou.lib_baselib.base.vm.BaseViewModel
import com.guadou.lib_baselib.bean.DataBindingConfig
import com.guadou.lib_baselib.ext.vertical
import com.guadou.lib_baselib.utils.CommUtils
import com.hongyegroup.cpt_rewards.R
import com.hongyegroup.cpt_rewards.databinding.FragmentMyRewardsActiveBinding
import com.hongyegroup.cpt_rewards.mvvm.MyRewardsActiveViewModel
import com.hongyegroup.cpt_rewards.ui.RewardsVerificationCodeActivity

class MyRewardsActiveFragment : BaseVDBLazyLoadingFragment<MyRewardsActiveViewModel, FragmentMyRewardsActiveBinding>() {


    override fun getDataBindingConfig(): DataBindingConfig {

        return DataBindingConfig(R.layout.fragment_my_rewards_active)

    }

    override fun startObserve() {

    }

    override fun init(savedInstanceState: Bundle?) {

        initListener()

    }

    private fun initListener() {


        //添加点击事件
        mViewModel.mActiveAdapter.addChildClickViewIds(R.id.tv_item_rewards_active_redeem_now)

        //设置点击监听
        mViewModel.mActiveAdapter.setOnItemChildClickListener { adapter, view, position ->

            var viewId=view.id
            if (viewId==R.id.tv_item_rewards_active_redeem_now){

                RewardsVerificationCodeActivity.startInstance()

            }

        }

    }

    override fun initViews(view: View) {
        super.initViews(view)

        for (index in 0..9){

            mViewModel.mActiveRewardsData.add("")

        }

        mBinding.recyclerViewMyRewardsActive.vertical().adapter=mViewModel.mActiveAdapter
        mViewModel.mActiveAdapter.notifyDataSetChanged()


    }

    override fun onLazyInitData() {

        CommUtils.getHandler().postDelayed(Runnable {

            showStateSuccess()

        }, 200)

    }
}