lmw
2023-06-13 adf8013576cbdd12e5ebea8ff7e32baf5d558b27
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
package com.kuanzhai.user.ui.mine.adapter
 
import android.view.View
import android.widget.TextView
import cn.sinata.xldutils.adapter.HFRecyclerAdapter
import cn.sinata.xldutils.adapter.util.ViewHolder
import cn.sinata.xldutils.gone
import cn.sinata.xldutils.visible
import com.kuanzhai.user.R
import com.kuanzhai.user.interfaces.StringCallback
import com.kuanzhai.user.network.entity.Order
import com.kuanzhai.user.utils.Const
import org.jetbrains.anko.textColorResource
 
data class TripOrderAdapter(val datas:ArrayList<Order>,val callback:StringCallback):HFRecyclerAdapter<Order>(datas, R.layout.item_order) {
    override fun onBind(holder: ViewHolder, position: Int, data: Order) {
        val tv_tag = holder.bind<TextView>(R.id.tv_tag)
        val tv_thank = holder.bind<View>(R.id.tv_thank)
        val tv_thank_money = holder.bind<TextView>(R.id.tv_thank_money)
 
        tv_tag.visibility = if (data.orderType == 1) {
            tv_tag.text = data.getRideTypeStr()
            View.VISIBLE
        } else View.GONE
        holder.setText(R.id.tv_time,data.orderTime)
        holder.setText(R.id.tv_trip_time,data.time)
        holder.setText(R.id.tv_start,data.startAddress)
        holder.setText(R.id.tv_end,data.endAddress)
        holder.setText(R.id.tv_state,data.getStateStr())
        holder.bind<TextView>(R.id.tv_state).textColorResource = data.getStateColor()
        holder.bind<TextView>(R.id.tv_count).apply {
            visibility = if (data.orderType == Const.OrderType.TYPE_CROSS_CITY) {
                text = String.format("%d人",data.num)
                View.VISIBLE
            } else View.GONE
        }
        if (data.state == 8||data.state == 9){
            if (data.thankYouFee == 0.0){
                tv_thank_money.gone()
                tv_thank.visible()
                tv_thank.setOnClickListener {
                    callback.onRlt(position.toString())
                }
            }else{
                tv_thank_money.visible()
                tv_thank.gone()
                tv_thank_money.text = "答谢%.2f元".format(data.thankYouFee)
            }
        }else{
            tv_thank_money.gone()
            tv_thank.gone()
        }
    }
}