lmw
2023-06-13 4b7d8d9a038f6522df46d0f14fa07eb940a1b34d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package com.kuanzhai.driver.ui.driver_server.adapter
 
import android.view.View
import cn.sinata.xldutils.utils.*
import com.kuanzhai.driver.R
import com.kuanzhai.driver.base.BaseRvAdapter
import com.kuanzhai.driver.base.BaseViewHolder
import com.kuanzhai.driver.bean.MyBuyCarListData
import com.kuanzhai.driver.netUtls.Api
import com.kuanzhai.driver.netUtls.callNet
import com.kuanzhai.driver.netUtls.getMapByAny
import com.kuanzhai.driver.ui.DialogUtil
import com.kuanzhai.driver.utils.glide.GlideUtil
import kotlinx.android.synthetic.main.item_conpon_merchant_mine.view.*
import kotlinx.android.synthetic.main.item_rental_list_buy.view.*
 
class BuyListAdapter:BaseRvAdapter<MyBuyCarListData>() {
 
    var type = 1 // 1 服务列表 2 我的列表
 
    override fun getLayoutResId(viewType: Int): Int {
        return R.layout.item_rental_list_buy
    }
 
    override fun onBindItem(holder: BaseViewHolder?, view: View?, item: MyBuyCarListData?) {
        holder?.itemView?.apply {
            tv_statue.gone()
            iv_delete.gone()
            if (type == 2){
                tv_statue.visible()
                view_meng.visible()
                if (item!!.status != 1 && item!!.status != 2 ) {
                    iv_delete.visible()
                }
            }
            tv_statue.textColor(context,R.color.white)
            if (item!!.status == 5){
                tv_statue.textColor(context,R.color.red_main)
            }
            if (item.imgUrl.isNotEmpty()){
                GlideUtil.load(context,item.imgUrl.split(",")[0],iv_img,2)
            }
            tv_type_name.text = if (item!!.userType == 3) "企业车辆" else "个人车辆"
            tv_statue.text = item.getStatueStr()
            tv_content.text = item.title
            tv_content_dis.text = item.mileage+"万公里/"+ item.licensingTime+"/"+item.cityName
            tv_price.text = doubleTwo(item.getTransferPriceStr()/10000) +"万"
            iv_delete.clickDelay {
                DialogUtil.getDelAndSureDialog(context,"删除后数据将不会恢复,确认删除?",{}){
                    var map = getMapByAny()
                    map["id"] = item.id
                    map["type"] = 2
                    callNet(context,Api.delete,map){
                        data.removeAt(holder.adapterPosition)
                        notifyDataSetChanged()
                    }
                }
            }
        }
    }
}