package com.zxhl.cms.pay.view

import android.view.View
import androidx.recyclerview.widget.GridLayoutManager
import com.zxhl.cms.R
import com.zxhl.cms.common.Constant
import com.zxhl.cms.common.base.BaseActivity
import com.zxhl.cms.net.model.chat.RecordEntity
import com.zxhl.cms.net.model.pay.CoinStoreEntity
import com.zxhl.cms.pay.adapter.CoinStoreAdapter
import com.zxhl.cms.pay.contract.CoinStoreContract
import com.zxhl.cms.pay.presenter.CoinStorePresenter
import com.zxhl.cms.utils.JumpUtils
import com.zxhl.cms.utils.OnRecycleItemClickListener
import kotlinx.android.synthetic.main.activity_layout_coin_store.*
import kotlinx.android.synthetic.main.activity_layout_coin_store.id_img_back

class CoinStoreActivity : BaseActivity(), CoinStoreContract.View,
    OnRecycleItemClickListener<RecordEntity> {
    private var mAdapter: CoinStoreAdapter? = null
    private var mPresenter: CoinStorePresenter? = null
    override fun init() {

        mPresenter = CoinStorePresenter(this)

        mAdapter = CoinStoreAdapter(this, this)
        id_rcl_pay_coin_list?.layoutManager = GridLayoutManager(this, 2)
        id_rcl_pay_coin_list?.adapter = mAdapter

        id_img_coin_record.setOnClickListener(this)
        id_img_back.setOnClickListener(this)

        mPresenter?.getCoinPayList()
        mPresenter?.getUserCoins()
    }

    override fun onClick(v: View?) {
        when (v) {
            id_img_coin_record -> {
                showToast("id_img_coin_record")
            }
            id_img_back -> {
                finish()
            }
        }
    }

    override fun layoutID(): Int {
        return R.layout.activity_layout_coin_store
    }

    override fun setCoinPayList(result: List<CoinStoreEntity>?) {

    }

    override fun setUserCoins(coinNum: Double) {
        id_tv_user_coins_num.text = "$coinNum"
    }

    override fun onItemClick(view: View?, position: Int, data: RecordEntity?) {
        JumpUtils.paymentPageJump(Constant.Key.PAY_TYPE_COIN,"1","name","0.0")
    }
}