From 71a056d02f9084af82bd6fe3962e5b46d5628e4f Mon Sep 17 00:00:00 2001 From: liugl <liugl@sinata.cn> Date: 星期二, 11 八月 2020 21:56:10 +0800 Subject: [PATCH] 8.11 --- app/src/main/java/com/okgoincar/slab/SlabOrderOverActivity.kt | 56 ++++++++++++++++++++++++++++++++++++++++++++------------ 1 files changed, 44 insertions(+), 12 deletions(-) diff --git a/app/src/main/java/com/okgoincar/slab/SlabOrderOverActivity.kt b/app/src/main/java/com/okgoincar/slab/SlabOrderOverActivity.kt index 68d7048..8136ab7 100644 --- a/app/src/main/java/com/okgoincar/slab/SlabOrderOverActivity.kt +++ b/app/src/main/java/com/okgoincar/slab/SlabOrderOverActivity.kt @@ -15,6 +15,7 @@ import com.okgoincar.netUtls.timeOver import com.okgoincar.utils.MyUtils import kotlinx.android.synthetic.main.activity_order_over.* +import java.lang.Exception class SlabOrderOverActivity : MySlabBaseActivity() { @@ -42,7 +43,7 @@ override fun onPause() { super.onPause() if (time != null){ - time!!.onFinish() + time!!.cancel() } } @@ -97,8 +98,8 @@ callNet(this, Api.queryOrderInfo, map) { orderBean = gson.fromJson(it, OrderBean::class.java) showUi(orderBean) - addSocketLisener() - +// addSocketLisener() + checkOrderStatue() } } @@ -111,6 +112,7 @@ MyUtils.getInstans().CallPhone(this, it.data.phone.toString()) } tv_pay_result_money.text = "¥" + it.data.orderMoney.toString() + tv_pay_result_small_money.text = "¥" + it.data.tipMoney.toString() tv_time.text = it.data.travelTime tv_start_address.text = it.data.startAddress tv_end_address.text = it.data.endAddress @@ -148,10 +150,16 @@ if (it.status == 8||it.status == 7) { tv_pay_result_money.textColor(this@SlabOrderOverActivity,R.color.slab_green_over) Handler(Looper.getMainLooper()).post { - time = timeOver (5000){ + time = timeOver (20000){ tv_title_slab.text = "已完成($it)" if (it == 0){ - onBackPressed() + if (time != null){ + time!!.cancel() + } + try { + onBackPressed() + }catch (e:Exception){ + } } } } @@ -173,26 +181,50 @@ // } } - var handler: android.os.Handler? = null + var handler: Handler? = null fun checkOrderStatue() { + if (handler == null) { + handler = Handler(mainLooper) + handler!!.postDelayed({ + checkOrderStatue() + }, 3000) + } var map = getMapByAny() map["orderId"] = orderId map["orderType"] = orderType - callNet(false,Api.orderStateSocket, map) { + callNet(false,Api.queryOrderInfo, map) { val orderSimpleData = Gson().fromJson( it, - OrderSimpleData::class.java + OrderBean::class.java ) orderSimpleData?.let { - if (orderSimpleData.status == 8) { - orderBean.data.orderState = 8 - showUi(orderBean) + if (it.data.orderState == 8) { + tv_pay_result_money.textColor( + this@SlabOrderOverActivity, + R.color.slab_green_over + ) + Handler(Looper.getMainLooper()).post { + MyApplication.getTTsManager().setVideoText("乘客已支付"+it.data.orderMoney.toString()+"元") + time = timeOver(20000) { + tv_title_slab.text = "已完成($it)" + if (it == 0) { + if (time != null) { + time!!.cancel() + } + try { + onBackPressed() + } catch (e: Exception) { + } + } + } + } + }else{ + handler?.postDelayed({ checkOrderStatue() }, 3000) } } } - handler?.postDelayed({ checkOrderStatue() }, 3000) } override fun onDestroy() { -- Gitblit v1.7.1