package com.driver.igotrip.ui.main.small_cargo
|
|
import android.os.Looper
|
import android.view.View
|
import android.widget.LinearLayout
|
import android.widget.TextView
|
import cn.sinata.xldutils.utils.*
|
import com.driver.igotrip.R
|
import com.driver.igotrip.base.BaseEvent
|
import com.driver.igotrip.base.MyApplication
|
import com.driver.igotrip.base.MyApplication.Companion.appContext
|
import com.driver.igotrip.base.MyBaseActivity
|
import com.driver.igotrip.bean.OrderBean
|
import com.driver.igotrip.bean.OrderSimpleData
|
import com.driver.igotrip.netUtls.Api
|
import com.driver.igotrip.netUtls.callNet
|
import com.driver.igotrip.netUtls.getMapByAny
|
import com.driver.igotrip.ui.UiUtil
|
import com.driver.igotrip.ui.main.major.MajorMoneyDetailActivity
|
import com.driver.igotrip.utils.MyUtils
|
import com.driver.igotrip.utils.view.SlidingButton
|
import com.google.gson.Gson
|
import org.greenrobot.eventbus.EventBus
|
import org.jetbrains.anko.find
|
import org.jetbrains.anko.startActivity
|
|
class SmallOverActivity : MyBaseActivity(), MyApplication.OrderStatueView {
|
|
private val orderBean by lazy { intent.getSerializableExtra("orderBean") as OrderBean.DataBean }
|
|
override fun setContentView() {
|
setContentView(R.layout.activity_order_over_small)
|
|
}
|
|
private val ll_order_cancel by lazy { find<View>(R.id.ll_order_cancel) }
|
private val iv_phone by lazy { find<View>(R.id.iv_phone) }
|
private val tv_show_pay_over by lazy { find<TextView>(R.id.tv_show_pay_over) }
|
private val tv_name by lazy { find<TextView>(R.id.tv_name) }
|
private val tv_car_num by lazy { find<TextView>(R.id.tv_car_num) }
|
private val tv_time by lazy { find<TextView>(R.id.tv_time) }
|
private val tv_start_address by lazy { find<TextView>(R.id.tv_start_address) }
|
private val tv_end_address by lazy { find<TextView>(R.id.tv_end_address) }
|
private val tv_money_cargo by lazy { find<TextView>(R.id.tv_money_cargo) }
|
private val tv_remark by lazy { find<TextView>(R.id.tv_remark) }
|
private val ll_order_money by lazy { find<LinearLayout>(R.id.ll_order_money) }
|
private val tv_order_money by lazy { find<TextView>(R.id.tv_order_money) }
|
private val ll_service_money by lazy { find<LinearLayout>(R.id.ll_service_money) }
|
private val tv_service_money by lazy { find<TextView>(R.id.tv_service_money) }
|
private val ll_real_income by lazy { find<LinearLayout>(R.id.ll_real_income) }
|
private val tv_real_income by lazy { find<TextView>(R.id.tv_real_income) }
|
private val tv_pay_result_small_money by lazy { find<TextView>(R.id.tv_pay_result_small_money) }
|
private val tv_tv_num_cargo by lazy { find<TextView>(R.id.tv_tv_num_cargo) }
|
private val tv_people_cargo by lazy { find<TextView>(R.id.tv_people_cargo) }
|
private val tv_pay_result_money by lazy { find<TextView>(R.id.tv_pay_result_money) }
|
private val tv_pay_result_title by lazy { find<TextView>(R.id.tv_pay_result_title) }
|
private val tv_cancel_to by lazy { find<TextView>(R.id.tv_cancel_to) }
|
private val tv_cancel_money by lazy { find<TextView>(R.id.tv_cancel_money) }
|
private val tv_cancel_result by lazy { find<TextView>(R.id.tv_cancel_result) }
|
private val tv_cancel_s by lazy { find<TextView>(R.id.tv_cancel_s) }
|
private val ll_pay_result by lazy { find<LinearLayout>(R.id.ll_pay_result) }
|
private val view_line_money_detail by lazy { find<View>(R.id.view_line_money_detail) }
|
private val tv_frozen by lazy { find<TextView>(R.id.tv_frozen) }
|
|
override fun initView() {
|
setTitleText(getString(R.string.已送达))
|
ll_order_cancel.gone()
|
MyApplication.currentOrderType = ""
|
MyApplication.currentOrderId = ""
|
tv_show_pay_over.gone()
|
ll_pay_result.gone()
|
tv_show_pay_over.text = getString(R.string.客户已支付)
|
// callOrder()
|
addSocketLisener()
|
showUi(orderBean)
|
}
|
|
|
private fun showUi(orderBean: OrderBean.DataBean) {
|
orderBean?.let {
|
setTitleText(getString(R.string.交货))
|
tv_name.text = it.userName
|
tv_car_num.text = getString(R.string.次寄物, it.historyNum.toString())
|
iv_phone.visible()
|
iv_phone.clickDelay {
|
MyUtils.getInstans().CallPhone(this, it.userPhone)
|
}
|
tv_time.text = it.travelTime_
|
tv_start_address.text = it.startAddress
|
tv_end_address.text = it.endAddress
|
tv_money_cargo.text = getString(R.string.元加急费, doubleTwo(it.tipMoney))
|
tv_remark.text = it.remark
|
if (it.tipMoney == null || it.tipMoney <= 0.0) {
|
tv_money_cargo.gone()
|
tv_pay_result_small_money.gone()
|
}
|
var cargoStrType =
|
if (it.cargoType == "1") getString(R.string.普通小件X) else getString(
|
R.string.贵重物品X
|
)
|
tv_tv_num_cargo.text = cargoStrType + it.peopleNumber
|
tv_people_cargo.text = it.nickName + "-" + it.phone
|
tv_pay_result_money.text =
|
"FCFA" + if (it.payMoney == 0.0) it.orderMoney.toString() else it.payMoney.toString()
|
tv_pay_result_small_money.text =
|
getString(R.string.其中含加急费用) + it.tipMoney.toString()
|
setTitleText(getSmallStatue(it.orderState))
|
tv_pay_result_title.text = getString(R.string.订单) + getSmallStatue(it.orderState)
|
tv_order_money.text = getString(R.string.money) + it.orderMoney
|
tv_service_money.text = getString(R.string.money) + it.platformServerMoney
|
tv_real_income.text = getString(R.string.money) + it.driverServerMoney
|
ll_pay_result.visible()
|
if (it.orderState in 6..7) {
|
tv_pay_result_title.text = getString(R.string.待乘客支付)
|
} else if (it.orderState == 8) {
|
tv_pay_result_title.text = getString(R.string.订单待评价)
|
} else if (it.orderState == 9) {
|
tv_pay_result_title.text = getString(R.string.订单已完成)
|
} else if (it.orderState == 10 || it.orderState == 12) {
|
ll_order_cancel.visible()
|
iv_phone.gone()
|
ll_pay_result.gone()
|
tv_cancel_to.text = it.cancelUser
|
tv_cancel_money.text =
|
getString(R.string.money) + " " + doubleOne(it.cancelPayMoney)
|
tv_cancel_result.text = it.cancelReason
|
tv_cancel_s.text = it.cancelRemark
|
if (it.cancelRemark.isNullOrEmpty()) {
|
tv_cancel_s.text = ""
|
}
|
}
|
|
if (it.orderState in 6..9) {
|
tv_pay_result_small_money.text = getString(R.string.查看收费明细)
|
tv_pay_result_small_money.visible()
|
view_line_money_detail.visible()
|
tv_pay_result_small_money.clickDelay {
|
startActivity<MajorMoneyDetailActivity>(
|
"orderId" to orderBean.orderId.toString(),
|
"orderType" to "4"
|
)
|
}
|
}
|
if (it.isFrozen == 2) {
|
tv_frozen.visible()
|
tv_frozen.setCompoundDrawablesRelativeWithIntrinsicBounds(
|
0,
|
UiUtil.getFrozenBitmap(), 0, 0
|
)
|
}
|
}
|
}
|
|
private fun getSmallStatue(state: Int): String? {
|
when (state) {
|
1 -> return getString(R.string.待接单)
|
2 -> return getString(R.string.待出发)
|
3 -> return getString(R.string.待到达预约地点)
|
4 -> return getString(R.string.待取货)
|
5 -> return getString(R.string.送货中)
|
6 -> return getString(R.string.已送达)
|
7 -> return getString(R.string.待支付)
|
8 -> return getString(R.string.待评价)
|
9 -> return getString(R.string.已完成)
|
10 -> return getString(R.string.cancel_ed)
|
11 -> return getString(R.string.改派中)
|
12 -> return getString(R.string.取消待支付)
|
13 -> return getString(R.string.需补差价)
|
}
|
return ""
|
}
|
|
private fun addSocketLisener() {
|
MyApplication.addOrderView(this)
|
|
// if (handler == null) {
|
// handler = android.os.Handler(mainLooper)
|
// handler!!.postDelayed({
|
// checkOrderStatue()
|
// }, 3000)
|
// }
|
}
|
|
var handler: android.os.Handler? = null
|
fun checkOrderStatue() {
|
var map = getMapByAny()
|
map["orderId"] = orderBean.orderId
|
map["orderType"] = "4"
|
callNet(false, Api.orderStateSocket, map) {
|
val orderSimpleData =
|
Gson().fromJson(
|
it,
|
OrderSimpleData::class.java
|
)
|
orderSimpleData?.let {
|
if (orderSimpleData.status == 8) {
|
orderBean.orderState = 8
|
showUi(orderBean)
|
}
|
}
|
}
|
handler?.postDelayed({ checkOrderStatue() }, 3000)
|
}
|
|
override fun onDestroy() {
|
super.onDestroy()
|
handler?.removeCallbacksAndMessages(null)
|
MyApplication.removeOrderView(this)
|
}
|
|
override fun onBackPressed() {
|
super.onBackPressed()
|
EventBus.getDefault().post(BaseEvent(BaseEvent.CALL_NUM_MAIN))
|
EventBus.getDefault().post(BaseEvent(BaseEvent.BACK_CAR_OVER))
|
}
|
|
override fun setOnclick() {
|
|
}
|
|
override fun orderInfo(data: OrderSimpleData?) {
|
data?.let {
|
if (it.status == 8) {
|
android.os.Handler(Looper.getMainLooper()).post {
|
orderBean.orderState = 8
|
showUi(orderBean)
|
}
|
}
|
}
|
}
|
}
|