package com.zxhl.main.page.activity

import android.util.Log
import android.view.View
import androidx.recyclerview.widget.LinearLayoutManager
import com.zxhl.cms.AppContext
import com.zxhl.cms.common.base.BaseActivity
import com.zxhl.cms.net.model.box.DepotEntity
import com.zxhl.cms.net.model.box.LotteryEntity
import com.zxhl.main.R
import com.zxhl.main.page.adapter.DepotRecoverDetailAdapter
import com.zxhl.main.page.adapter.RecoverDetailAdapter
import kotlinx.android.synthetic.main.activity_layout_recover_detail.*

class RecoverDetailActivity : BaseActivity() {
    private var mAdapter: RecoverDetailAdapter? = null
    private var mDepotAdapter: DepotRecoverDetailAdapter? = null
    private var intentlist: List<LotteryEntity>? = null
    private var depotlist: List<DepotEntity>? = null
    override fun onClick(v: View?) {

    }

    override fun layoutID(): Int {
        return R.layout.activity_layout_recover_detail
    }
    override fun before() {
        super.before()
        setStatusBarBackground(AppContext.get().resources.getColor(R.color.transparent))
    }
    override fun init() {

        if(intent.getSerializableExtra("intentList")!=null){
            intentlist = intent.getSerializableExtra(
                "intentList"
            ) as List<LotteryEntity>
        }

        if (intent.getSerializableExtra("depotList") != null) {
            depotlist = intent.getSerializableExtra(
                "depotList"
            ) as List<DepotEntity>
        }

        id_img_back?.setOnClickListener {
            finish()
        }
        mAdapter = RecoverDetailAdapter(this)
        mDepotAdapter = DepotRecoverDetailAdapter(this)
        id_rl_recover_detail?.layoutManager = LinearLayoutManager(this)
        if (intentlist != null) {
            id_rl_recover_detail.adapter = mAdapter
            setData(intentlist)
            Log.e("MXL", "抽奖页的明细")
        } else {
            Log.e("MXL", "仓库页的明细")
            id_rl_recover_detail.adapter = mDepotAdapter
            setDepotData(depotlist)
        }


    }

    fun setData(list: List<LotteryEntity>?) {
        mAdapter?.clear()
        mAdapter?.appendToList(list)
        mAdapter?.notifyDataSetChanged()
    }

    fun setDepotData(list: List<DepotEntity>?) {
        mDepotAdapter?.clear()
        mDepotAdapter?.appendToList(list)
        mDepotAdapter?.notifyDataSetChanged()
    }
}