package com.zxbw.modulemain.activity

import android.view.View
import androidx.recyclerview.widget.LinearLayoutManager
import com.zxbw.modulemain.R
import com.zxbw.modulemain.adapter.GoodsListAdapter
import com.zxbw.modulemain.contract.ZeroBuyListContract
import com.zxbw.modulemain.presenter.ZeroBuyListPresenter
import com.zxhl.cms.AppContext
import com.zxhl.cms.common.base.BaseActivity
import com.zxhl.cms.net.model.qy.TbGoodsItemEntity
import com.zxhl.cms.utils.OnRecycleItemClickListener
import kotlinx.android.synthetic.main.activity_layout_zero_buy_list.*

/**
 * @author (wangXuewei)
 * @datetime 2022-05-24 14:08 GMT+8
 * @detail :零元购列表
 */
class ZeroBuyListActivity : BaseActivity(), ZeroBuyListContract.View,
    OnRecycleItemClickListener<TbGoodsItemEntity> {

    private var mPresenter: ZeroBuyListPresenter? = null
    private var mAdapter: GoodsListAdapter? = null;

    override fun layoutID(): Int {
        return R.layout.activity_layout_zero_buy_list
    }
    override fun before() {
        super.before()
        setStatusBarBackground(AppContext.get().resources.getColor(R.color.transparent))
    }
    override fun onClick(v: View?) {
        when (v) {
            id_img_back -> {
                finish()
            }
        }
    }

    override fun init() {
        mPresenter = ZeroBuyListPresenter(this)

        id_img_back?.setOnClickListener(this)

        mAdapter = GoodsListAdapter(this, this)
        id_rcl_zero_buy_list?.layoutManager = LinearLayoutManager(this)
        id_rcl_zero_buy_list.adapter = mAdapter

        id_zero_buy_refreshLayout.setOnRefreshListener{
            mPresenter?.getZeroBuyList()
        }


        mPresenter?.getZeroBuyList()
    }

    override fun onItemClick(view: View?, position: Int, data: TbGoodsItemEntity?) {

    }

    override fun setZeroBuyList(isRefresh: Boolean, result: List<Any>?) {
        id_zero_buy_refreshLayout?.isRefreshing = false

    }

}