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)
|
}
|
}
|
}
|
}
|
|
}
|