package com.zj365.mime.act

import android.view.View
import androidx.recyclerview.widget.LinearLayoutManager
import com.alibaba.android.arouter.facade.annotation.Route
import com.xty.base.act.BaseVmAct
import com.xty.common.arouter.ARouterUrl
import com.xty.common.arouter.RouteManager
import com.xty.common.recycleUtils.RecycleItem
import com.zj365.mime.adapter.VersionAdapter
import com.zj365.mime.databinding.ActVersionListBinding
import com.zj365.mime.vm.VersionVm

/**
 * 版本列表
 */
@Route(path = ARouterUrl.VERSION_LIST)
class VersionList: BaseVmAct<VersionVm>() {
    val mAdapter by lazy{ VersionAdapter() }
    val binding by lazy{ActVersionListBinding.inflate(layoutInflater)}
    var openSettingFlag = 0;
    override fun setLayout()=binding.root
    override fun initData() {
        super.initData()
        isDarkBar=true
    }

    override fun initView() {
        super.initView()
        statusBar(binding.title.mView)
        binding.title.mIvBack.setOnClickListener { finish() }
        binding.title.mTvTitle.text="版本列表"
        binding.title.mTvRight.text = "              "
        binding.title.mTvRight.visibility = View.VISIBLE
        binding.title.mTvRight.setOnClickListener {
            openSettingFlag++
            if (openSettingFlag > 5){
                RouteManager.goAct(ARouterUrl.DEBUG)
            }
        }

        binding.mRecycle.addItemDecoration(RecycleItem(this,10))
        binding.mRecycle.adapter=mAdapter
        binding.mRecycle.layoutManager=LinearLayoutManager(this)
        mViewModel.getVersion()


    }

    override fun liveObserver() {
        mViewModel.versionLive.observe(this){
            mAdapter.setNewInstance(it.data)
        }
    }
}