package com.lukouguoji.gnj.page.yiku.details

import android.content.Context
import android.content.Intent
import android.os.Bundle
import com.alibaba.android.arouter.facade.annotation.Route
import com.lukouguoji.gnj.R
import com.lukouguoji.gnj.databinding.ActivityGnjYikuDetailsBinding
import com.lukouguoji.module_base.base.BaseBindingActivity
import com.lukouguoji.module_base.common.Constant
import com.lukouguoji.module_base.ktx.commonAdapter
import com.lukouguoji.module_base.router.ARouterConstants

/**
 * 国内进港移库详情页
 */
@Route(path = ARouterConstants.ACTIVITY_URL_GNJ_YIKU_DETAILS)
class GnjYiKuDetailsActivity :
    BaseBindingActivity<ActivityGnjYikuDetailsBinding, GnjYiKuDetailsViewModel>() {

    override fun layoutId() = R.layout.activity_gnj_yiku_details

    override fun viewModelClass() = GnjYiKuDetailsViewModel::class.java

    override fun initOnCreate(savedInstanceState: Bundle?) {
        setBackArrow("国内进港移库记录")

        viewModel.initOnCreated(intent)
        binding.viewModel = viewModel

        // 监听图片列表变化并更新adapter
        viewModel.imageList.observe(this) { images ->
            binding.rvImages.commonAdapter()?.refresh(images)
        }
    }

    companion object {
        @JvmStatic
        fun start(context: Context, id: String) {
            val starter = Intent(context, GnjYiKuDetailsActivity::class.java)
                .putExtra(Constant.Key.ID, id)
            context.startActivity(starter)
        }
    }
}
