package com.hongyegroup.cpt_main.mvvm

import android.annotation.SuppressLint
import androidx.lifecycle.SavedStateHandle
import com.guadou.cs_cptservices.adapter.BannerGlobalAdapter
import com.guadou.cs_cptservices.binding.BaseDataBindingAdapter
import com.guadou.lib_baselib.base.vm.BaseViewModel
import com.hongyegroup.cpt_main.BR
import com.hongyegroup.cpt_main.R
import dagger.hilt.android.lifecycle.HiltViewModel
import javax.inject.Inject

@HiltViewModel
class HomeViewModel @Inject constructor(
    private val savedStateHandle: SavedStateHandle
) : BaseViewModel() {

    private val hotJobs = mutableListOf<String>()
    private val cityJobs = mutableListOf<String>()
    private val areaJobs = mutableListOf<String>()
    private val jobTips = mutableListOf<String>()
    private val imgUrls = mutableListOf<String>()

    val mHotJobAdapter by lazy { BaseDataBindingAdapter(R.layout.item_home_part_time_job, BR.item, hotJobs) }
    val mCityJobAdapter by lazy { BaseDataBindingAdapter(R.layout.item_home_part_time_job, BR.item, cityJobs) }
    val mAreaJobAdapter by lazy { BaseDataBindingAdapter(R.layout.item_home_part_time_job, BR.item, areaJobs) }
    val mJobTipsAdapter by lazy { BaseDataBindingAdapter(R.layout.item_home_job_tips, BR.item, jobTips) }
    val mBannerAdapter by lazy { BannerGlobalAdapter(imgUrls) }


    @SuppressLint("NotifyDataSetChanged")
    fun setupDataes() {
        hotJobs.clear()
        for (i in 1..6) {
            hotJobs.add("http://malaysia-yyjobs-admin-dev.guabean.com/storage/202206/09/9NdPaX0fB66dFc4SMuR2kIqLDiJcVGjTW6vZ9hUu-690x410.png")
        }
        mHotJobAdapter.notifyDataSetChanged()

        cityJobs.clear()
        for (i in 1..4) {
            cityJobs.add("http://malaysia-yyjobs-admin-dev.guabean.com/storage/202206/09/9NdPaX0fB66dFc4SMuR2kIqLDiJcVGjTW6vZ9hUu-690x410.png")
        }
        mCityJobAdapter.notifyDataSetChanged()

        areaJobs.clear()
        for (i in 1..5) {
            areaJobs.add("http://malaysia-yyjobs-admin-dev.guabean.com/storage/202206/09/9NdPaX0fB66dFc4SMuR2kIqLDiJcVGjTW6vZ9hUu-690x410.png")
        }
        mAreaJobAdapter.notifyDataSetChanged()

        jobTips.clear()
        for (i in 1..4) {
            jobTips.add("http://malaysia-yyjobs-admin-dev.guabean.com/storage/202206/09/9NdPaX0fB66dFc4SMuR2kIqLDiJcVGjTW6vZ9hUu-690x410.png")
        }
        mJobTipsAdapter.notifyDataSetChanged()

        imgUrls.clear()
        imgUrls.add("http://yyjobs-admin-dev.guabean.com/storage/202206/21/5Kg5pL4lKlUkOijrntMucMw4CgbDMJbQ8ZfTXWjU-750x320.png")
        imgUrls.add("http://yyjobs-admin-dev.guabean.com/storage/202205/31/VX8sQRRgDXCC9nReU9hFx7Hhxg0karC1tQrWH74S-750x320.png")
        imgUrls.add("http://yyjobs-admin-dev.guabean.com/storage/202207/05/i049TYZ9GTf2BJ0jtc7cwa9zq7gtJGJhiVaUzcyB-1563x667.png")
        mBannerAdapter.notifyDataSetChanged()

    }
}