package com.zj365.mime.fragment

import android.text.Html
import android.view.View
import com.xty.base.fragment.BaseVmFrag
import com.xty.common.arouter.ARouterUrl
import com.xty.common.arouter.RouteManager
import com.xty.common.util.CommonUtils
import com.zj365.mime.databinding.FragNewProgBinding
import com.zj365.mime.vm.MyProgVm

class NewProgFrag : BaseVmFrag<MyProgVm>() {
    val binding by lazy { FragNewProgBinding.inflate(layoutInflater) }
    override fun initView() {
        super.initView()
        binding.mTvHistory.setOnClickListener {
            RouteManager.goAct(ARouterUrl.PROGRAMME_HISTORY)
        }

        CommonUtils.getMyUserInfo()?.let {
            mViewModel.getNesProg(it.id)
        }
    }

    override fun setViewModel() = MyProgVm()
    override fun observer() {
        mViewModel.progLive.observe(this) {
            if (it.data.isNotEmpty()) {
                binding.empty.emptyLayout.visibility = View.GONE
                it.data?.get(0)?.let {
                    binding.tvProgrammeName.text = it.name
                    binding.tvAgency.text = it.orgName
                    binding.tvTime.text = it.createTime
                    binding.mMsg.text = Html.fromHtml(it.prName)
                    // binding.title.mTvTitle.text = it.name
                }
            } else {
                binding.empty.emptyLayout.visibility = View.VISIBLE
            }
        }
    }

    override fun setLayout() = binding.root
}