package com.zxbw.modulemain.activity

import android.view.View
import androidx.recyclerview.widget.GridLayoutManager
import com.zxbw.modulemain.R
import com.zxbw.modulemain.adapter.FlashSaleAdapter
import com.zxbw.modulemain.adapter.MoreDiscountAdapter
import com.zxbw.modulemain.adapter.TimeAdapter
import com.zxbw.modulemain.contract.FlashSaleContract
import com.zxbw.modulemain.presenter.FlashSalePresenter
import com.zxhl.cms.AppContext
import com.zxhl.cms.common.base.BaseActivity
import com.zxhl.cms.net.model.qy.SkillEntity
import com.zxhl.cms.utils.OnRecycleItemClickListener
import kotlinx.android.synthetic.main.activity_layout_flash_sale.*

class FlashSaleActivity:BaseActivity(),FlashSaleContract.View,OnRecycleItemClickListener<SkillEntity> {
    private var mPresenter:FlashSalePresenter?=null
    private var mAdapter:FlashSaleAdapter?=null
    private var mDiscountAdapter:MoreDiscountAdapter?=null
    private var mTimeAdapter: TimeAdapter?=null
    override fun onClick(v: View?) {

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

    override fun init() {
        mPresenter= FlashSalePresenter(this)
        mAdapter= FlashSaleAdapter(this)
        mTimeAdapter= TimeAdapter(this,this)
        mDiscountAdapter= MoreDiscountAdapter(this)
        id_rl_time?.layoutManager=GridLayoutManager(this,4)
        id_rl_time?.adapter=mTimeAdapter
        id_rl_more_discount?.layoutManager=GridLayoutManager(this,3)
        id_rl_more_discount?.adapter=mDiscountAdapter
        id_rl_flash_sale_top?.layoutManager=GridLayoutManager(this,3)
        id_rl_flash_sale_top?.adapter=mAdapter
        mPresenter?.getFlashSaleData()
    }


    override fun setData(result: List<SkillEntity>?) {
        mTimeAdapter?.clear()
        mTimeAdapter?.appendToList(result)
        mTimeAdapter?.notifyDataSetChanged()
    }

    override fun onItemClick(view: View?, position: Int, data: SkillEntity?) {
        showToast("点击"+data?.startTime)
    }
}