lmw
2024-05-27 c00669a852702e1aa1326872bb916f9a079b57e2
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
package com.future.driver.ui.adapter
 
import android.view.View
import cn.sinata.xldutils.utils.*
import com.future.driver.R
import com.future.driver.base.BaseRvAdapter
import com.future.driver.base.BaseViewHolder
import com.future.driver.bean.OrderListBean
import com.future.driver.ui.main.FillOutActivity
import com.future.driver.ui.main.OrderOverActivity
import com.future.driver.ui.main.TripActivity
import com.future.driver.ui.main.major.MajorSureMoneyActivity
import com.future.driver.ui.main.small_cargo.SmallCargoActivity
import com.future.driver.ui.main.small_cargo.SmallOverActivity
import com.future.driver.ui.to_city.TripCityActivity
import kotlinx.android.synthetic.main.item_main_list.view.*
import org.jetbrains.anko.startActivity
 
class MainAdapter : BaseRvAdapter<OrderListBean.DataBean>() {
    override fun getLayoutResId(viewType: Int): Int {
        return R.layout.item_main_list
    }
 
    override fun onBindItem(holder: BaseViewHolder?, view: View?, item: OrderListBean.DataBean?) {
        holder?.let {
            it.itemView.tv_people_num.setDrawableLeft(R.mipmap.icon_end_point)
            it.itemView.tv_remark.setDrawableLeft(R.mipmap.icon_end_point)
            it.itemView.tv_money_cargo.gone()
            it.itemView.tv_type.text = item!!.name
            it.itemView.tv_statue.text = item.stateStr()
            it.itemView.tv_time.text = item.time
            it.itemView.tv_start.text = item.startAddress
            it.itemView.tv_end.text = if (item.endAddress.isNullOrEmpty()) "---" else item.endAddress
            when(item.type){
                1,2 -> {
                    it.itemView.tv_people_num.gone()
                    it.itemView.tv_remark.gone()
                }
                3 -> {
                    it.itemView.tv_people_num.visible()
                    it.itemView.tv_remark.visible()
                    it.itemView.tv_remark.text = item.remark
                    if (item.remark.isNullOrEmpty()){
                        it.itemView.tv_remark.gone()
                    }else{
                        it.itemView.tv_remark.visible()
                    }
                    it.itemView.tv_people_num.text = "乘车人数"+item.peopleNumber+"人"
                }
                4,5 -> {
                    it.itemView.tv_people_num.setDrawableLeft(R.mipmap.icon_people_gray)
                    it.itemView.tv_remark.setDrawableLeft(R.mipmap.icon_item)
                    it.itemView.tv_people_num.text =item.user
                    it.itemView.tv_remark.text = item.cargoNumber
                    if (item.redMoney > 0.0){
                        it.itemView.tv_money_cargo.visible()
                        it.itemView.tv_money_cargo.text = doubleTwo(item.redMoney)+"元加急费"
                    }
                }
            }
//     *     1=待接单,2=待出发,3=待到达预约地点,4=待取货,5=送货中,6=已送达,7=待支付,8=需补差价,9=已取货,10=已取消,11=改派中,12=已支付差价
 
            it.itemView.clickDelay {
                if (item.type == 4 || item.type == 5){
                    when(item.state){
                        1,2,3,4,5,7,8,9,12 ->{
                            context.startActivity<SmallCargoActivity>(
                                "orderId" to item.id.toString(),
                                "orderType" to item.type.toString()
                            )
                        }
                        6,10->{
                            context.startActivity<SmallOverActivity>(
                                "orderId" to item.id.toString(),
                                "orderType" to item.type.toString()
                            )
                        }
                        11 -> {
                            toast("订单改派中")
                        }
                    }
 
                    return@clickDelay
                }
                if(item.type ==1 || item.type ==2){ //订单类型(1=专车,2=出租车,3=城际,4=小件物流-同城,5=小件物流-跨城,6=包车)
                    when(item.state){
                        2,3,4,5 -> {
                            context.startActivity<TripActivity>("orderId" to item.id.toString() , "orderType" to item.type.toString())
                        }
                        6 ->{
                            if (item.type.toString() == "1"){
                                context.startActivity<MajorSureMoneyActivity>("orderId" to item.id.toString() , "orderType" to item.type.toString())
                            }
                            if (item.type.toString() == "2"){
                                context.startActivity<FillOutActivity>("orderId" to item.id.toString() , "orderType" to item.type.toString())
                            }
                        }
                        7,12->{
                            context.startActivity<OrderOverActivity>("orderId" to item.id.toString() , "orderType" to item.type.toString())
                        }
                        8,9,10 -> {
                            context.startActivity<OrderOverActivity>("orderId" to item.id.toString() , "orderType" to item.type.toString())
                        }
                        11 -> {
                            toast("正在改派中...")
                        }
                    }
                }
                if (item.type == 3){
                    if (item.state < 6){
                        context.startActivity<TripCityActivity>("orderId" to item.id.toString() , "orderType" to item.type.toString())
                    }else if(item.state == 6 || item.state == 8|| item.state == 9){
                        context.startActivity<TripCityActivity>("orderId" to item.id.toString() , "orderType" to item.type.toString())
                    }else{
                        when(item.state){
                            11 -> {
                                toast("订单改派中")
                            }
                            7,12-> {
                                toast("订单待支付")
                            }
                            10-> {
                                toast("订单已取消")
                            }
 
                        }
 
                    }
                }
            }
 
            it.itemView.tv_statue.textColor(context,R.color.color_orange_main)
            when(item.state){
                10 -> { //已取消 颜色
                    it.itemView.tv_statue.textColor(context,R.color.gray_93)
                }
            }
        }
    }
 
}