package com.lukouguoji.aerologic.page.gnj.unload.list

import android.content.Context
import android.content.Intent
import android.os.Bundle
import android.util.Log
import android.widget.CheckBox
import com.lukouguoji.aerologic.R
import com.lukouguoji.aerologic.databinding.ActivityCarListBinding
import com.lukouguoji.aerologic.databinding.ActivityGnjUnloadListBinding
import com.lukouguoji.module_base.base.BaseBindingActivity
import com.lukouguoji.module_base.ktx.addOnItemClickListener
import com.lukouguoji.module_base.ktx.getLifecycleOwner

class GnjUnloadListActivity :
    BaseBindingActivity<ActivityGnjUnloadListBinding, GnjUnloadListViewModel>() {

    override fun layoutId(): Int {
        return R.layout.activity_gnj_unload_list
    }

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

    override fun initOnCreate(savedInstanceState: Bundle?) {
        setBackArrow("国内进港卸机")
        binding.viewModel = viewModel
        viewModel.pageModel.bindSmartRefreshLayout(
            binding.srl,
            binding.rv,
            viewModel,
            getLifecycleOwner()
        )
        val checkbox: CheckBox = findViewById(R.id.checkbox)
        checkbox.setOnClickListener() {_ ->
            viewModel.refresh()
        }
        binding.rv.addOnItemClickListener(viewModel)
    }

    override fun onResume() {
        super.onResume()
        viewModel.refresh()
    }

    companion object {
        @JvmStatic
        fun start(context: Context) {
            val starter = Intent(context, GnjUnloadListActivity::class.java)
            context.startActivity(starter)
        }
    }
}