package com.lukouguoji.gnc.page.distribution.home

import android.content.Context
import android.content.Intent
import android.os.Bundle
import com.alibaba.android.arouter.facade.annotation.Route
import com.lukouguoji.gnc.R
import com.lukouguoji.gnc.databinding.ActivityDistributionHomeBinding
import com.lukouguoji.module_base.base.BaseBindingActivity
import com.lukouguoji.module_base.ktx.addOnItemClickListener
import com.lukouguoji.module_base.ktx.getLifecycleOwner
import com.lukouguoji.module_base.router.ARouterConstants

@Route(path = ARouterConstants.ACTIVITY_URL_GNC_DISTRIBUTION)
class GncDistributionHomeActivity :
    BaseBindingActivity<ActivityDistributionHomeBinding, GncDistributionHomeViewModel>() {

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

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

    override fun initOnCreate(savedInstanceState: Bundle?) {
        setBackArrow("国内出港货物分配")
        binding.viewModel = viewModel
        viewModel.pageModel.bindSmartRefreshLayout(
            binding.srl,
            binding.rv,
            viewModel,
            getLifecycleOwner()
        )

        binding.rv.addOnItemClickListener(viewModel)
    }

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

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

}