package com.kuanzhai.driver.ui.adapter
|
|
import android.view.View
|
import androidx.recyclerview.widget.LinearLayoutManager
|
import cn.sinata.xldutils.utils.clickDelay
|
import com.kuanzhai.driver.R
|
import com.kuanzhai.driver.base.BaseRvAdapter
|
import com.kuanzhai.driver.base.BaseViewHolder
|
import com.kuanzhai.driver.bean.MerchantCouponData
|
import com.kuanzhai.driver.utils.glide.GlideUtil
|
import kotlinx.android.synthetic.main.item_conpon_merchant_mine.view.*
|
|
class ConponMerchantMineAdapter: BaseRvAdapter<MutableList<MerchantCouponData>>() {
|
|
var type = 1 //1=正常,2=失效
|
|
override fun getLayoutResId(viewType: Int): Int {
|
return R.layout.item_conpon_merchant_mine
|
}
|
|
override fun onBindItem(holder: BaseViewHolder?, view: View?, item: MutableList<MerchantCouponData>?) {
|
holder?.let {
|
it.itemView.recycler_view_item.layoutManager = LinearLayoutManager(context)
|
var itemAdapter = ConponMerchantitemAdapter()
|
itemAdapter.type = type
|
itemAdapter.data.addAll(item!!)
|
it.itemView.recycler_view_item.adapter = itemAdapter
|
|
it.itemView.ll_bottom.clickDelay {
|
itemAdapter.isAll = !itemAdapter.isAll
|
itemAdapter.notifyDataSetChanged()
|
}
|
var hint = it.itemView.tv_hint_more
|
it.itemView.ll_bottom.visibility = if (item.size > 2) View.VISIBLE else View.GONE
|
hint.text = if (itemAdapter.isAll) "收起" else "展开"
|
GlideUtil.loady(context, item!![0].headImg,it.itemView.iv_head)
|
it.itemView.tv_name.text = item[0].merchantName
|
it.itemView.ll_bottom.clickDelay {
|
itemAdapter.isAll = !itemAdapter.isAll
|
itemAdapter.notifyDataSetChanged()
|
hint.text = if (it.itemView.tv_hint_more.text.toString() == "展开") "收起" else "展开"
|
}
|
|
}
|
}
|
|
}
|