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
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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
package com.kuanzhai.driver.ui.adapter
 
import android.view.View
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import cn.sinata.xldutils.activitys.ImagePagerActivity
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.OrderListBean
import com.kuanzhai.driver.ui.main.FillOutActivity
import com.kuanzhai.driver.ui.main.OrderOverActivity
import com.kuanzhai.driver.ui.main.TripActivity
import com.kuanzhai.driver.ui.main.TripPoolingActivity
import com.kuanzhai.driver.ui.main.major.MajorSureMoneyActivity
import com.kuanzhai.driver.ui.main.small_cargo.SmallCargoActivity
import com.kuanzhai.driver.ui.main.small_cargo.SmallOverActivity
import com.kuanzhai.driver.ui.pub.ImageActivity
import com.kuanzhai.driver.ui.to_city.TripCityActivity
import com.kuanzhai.driver.utils.glide.GlideUtil
import kotlinx.android.synthetic.main.activity_order_over_small.*
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.rl_overtime.gone()
            it.itemView.tv_people_num.setDrawableLeft(R.drawable.bg_point_main_color_black)
            it.itemView.tv_remark.setDrawableLeft(R.drawable.bg_point_main_color_black)
            it.itemView.ll_drover_img.visible()
            it.itemView.ll_user_img.visible()
            it.itemView.tv_money_cargo.gone()
            it.itemView.tv_pooling.gone()
            it.itemView.ll_small_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 = item.endAddress
            it.itemView.tv_end.visibility =
                if (item.endAddress.isNullOrEmpty()) View.GONE else View.VISIBLE
            when (item.type) {
                1 -> {
                    it.itemView.tv_people_num.gone()
                    it.itemView.tv_remark.gone()
                    if (item.rideType == "3") {
                        it.itemView.tv_statue.text = item.statePinStr()
//                        it.itemView.tv_statue.textColor(context, if (it.itemView.tv_statue.getContent() == "服务中") R.color.main_blue else R.color.gray_93)
                        it.itemView.tv_statue.textColor(context,R.color.orange_main)
                        it.itemView.tv_type.text = "快车拼车订单"
                        it.itemView.tv_people_num.visible()
                        it.itemView.tv_people_num.setDrawableLeft(R.mipmap.icon_people_gray)
                        it.itemView.tv_people_num.text = "乘坐人数共" + item.peopleNumber + "人"
                        it.itemView.tv_pooling.visible()
                        it.itemView.tv_pooling.textColor(
                            context,
                            if (item.spellSuccess == "0") R.color.white else R.color.orange_main
                        )
                        it.itemView.tv_pooling.text = if (item.spellSuccess == "0") "未拼成" else "已拼成"
                        it.itemView.tv_pooling.isSelected = item.spellSuccess == "0"
                    }
                }
                2 -> {
                    it.itemView.tv_people_num.gone()
                    it.itemView.tv_remark.gone()
                }
                3,8,9 -> {
                    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.rl_overtime.visible()
                    if (item.arriveTimeExpect.isNotEmpty()) {
                        it.itemView.tv_smart_time_show.text = "要求送达时间:" + item.arriveTimeExpect
                    } else {
                        it.itemView.rl_overtime.gone()
                    }
                    it.itemView.tv_overtime.text = if (item.timeOutState == 2) "" else "已超时"
                    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) + "元加急费"
 
                    }
                    it.itemView.ll_small_cargo.visible()
                    if (item.driverImg.isNullOrEmpty() && item.userImg.isNullOrEmpty()) {
                        it.itemView.ll_small_cargo.gone()
                    }
                    if (item.driverImg.isNullOrEmpty()) {
                        it.itemView.ll_drover_img.gone()
                    }
                    if (item.userImg.isNullOrEmpty()) {
                        it.itemView.ll_user_img.gone()
                    }
                    GlideUtil.load(context, item.driverImg, it.itemView.iv_image_mine, 2)
                    it.itemView.iv_image_mine.clickDelay {
                        context.startActivity<ImageActivity>("url" to item.driverImg)
                    }
                    var smallUserImgAdapter = SmallUserImgtargeAdapter()
                    it.itemView.recycler_view_user_img2.layoutManager =
                        LinearLayoutManager(context, RecyclerView.HORIZONTAL, false)
                    it.itemView.recycler_view_user_img2.adapter = smallUserImgAdapter
                    var list = item.userImg.split(",")
                    smallUserImgAdapter.data.addAll(list)
                    smallUserImgAdapter.notifyDataSetChanged()
 
                }
            }
//     *     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 == 2 || (item.type == 1 && item.rideType != "3")) { //订单类型(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 == 1 && item.rideType == "3") { //订单类型(1=快车,2=出租车,3=城际,4=小件物流-同城,5=小件物流-跨城,6=包车)
                    context.startActivity<TripPoolingActivity>(
                        "orderId" to item.id.toString(),
                        "orderType" to item.type.toString()
                    )
//                    when (item.state) {
//                        2, 3, 4, 5, 6 -> {
//                            context.startActivity<TripPoolingActivity>(
//                                "orderId" to item.id.toString(),
//                                "orderType" to item.type.toString()
//                            )
//                        }
//                        7, 12, 8, 9, 10 -> {
//                            context.startActivity<OrderOverActivity>(
//                                "orderId" to item.id.toString(),
//                                "orderType" to item.type.toString()
//                            )
//                        }
//                    }
                }
                if (item.type == 3||item.type == 7) {
                    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.orange_main)
            when (item.state) {
                10 -> { //已取消 颜色
                    if (item.rideType != "3")
                        it.itemView.tv_statue.textColor(context, R.color.gray_93)
                }
            }
        }
    }
 
}