package com.sixin.module_p.ui.enter.gj

import androidx.fragment.app.Fragment
import com.lukouguoji.module_base.base.BaseBindingFragment
import com.lukouguoji.module_base.base.CommonAdapter
import com.lukouguoji.module_base.interfaces.IOnItemClickListener
import com.lukouguoji.module_base.ktx.addOnItemClickListener
import com.lukouguoji.module_base.ktx.loge
import com.lukouguoji.module_base.ktx.refresh
import com.sixin.module_p.R
import com.sixin.module_p.databinding.FragmentGjBinding

class GjFragment : BaseBindingFragment<FragmentGjBinding, GjViewModel>() {
    override fun layoutId(): Int {
        return R.layout.fragment_gj
    }

    override fun viewModelClass(): Class<GjViewModel> {
        return GjViewModel::class.java
    }

    override fun initOnViewCreated() {
        binding.viewModel = viewModel

        binding.rv.adapter =
            CommonAdapter(requireContext(), R.layout.item_pda_action, GjViewHolder::class.java)

        binding.rv.addOnItemClickListener(object : IOnItemClickListener {
            override fun onItemClick(position: Int, type: Int) {
                viewModel.onItemClick(position)
            }
        })

        binding.rv.refresh(viewModel.actionList)
    }

    companion object {
        fun newInstance(): Fragment {
            return GjFragment()
        }
    }
}