From bd6a8872438a35d47821c5d5da7fe149e5fed3ab Mon Sep 17 00:00:00 2001 From: lmw <125975490@qq.com> Date: 星期三, 21 六月 2023 09:53:36 +0800 Subject: [PATCH] 处理收不到广播 --- app/src/main/java/com/okgoincar/slab/SlabOrderOverActivity.kt | 223 +++++++++++++++++++++++++++++++++++-------------------- 1 files changed, 143 insertions(+), 80 deletions(-) diff --git a/app/src/main/java/com/okgoincar/slab/SlabOrderOverActivity.kt b/app/src/main/java/com/okgoincar/slab/SlabOrderOverActivity.kt index 34b600a..488b11f 100644 --- a/app/src/main/java/com/okgoincar/slab/SlabOrderOverActivity.kt +++ b/app/src/main/java/com/okgoincar/slab/SlabOrderOverActivity.kt @@ -3,6 +3,7 @@ import android.os.CountDownTimer import android.os.Handler import android.os.Looper +import android.view.View import cn.sinata.xldutils.utils.* import com.okgoincar.netUtls.callNet import com.okgoincar.netUtls.getMapByAny @@ -14,8 +15,10 @@ import com.okgoincar.bean.OrderStatueBean import com.okgoincar.netUtls.Api import com.okgoincar.netUtls.timeOver +import com.okgoincar.slab.util.DialogUtil import com.okgoincar.utils.MyUtils import kotlinx.android.synthetic.main.activity_order_over.* +import kotlinx.android.synthetic.main.dialog_sure_and_del_slab.view.* import java.lang.Exception class SlabOrderOverActivity : MySlabBaseActivity() { @@ -28,7 +31,7 @@ intent.getStringExtra("orderId") } - var time:CountDownTimer? = null + var time: CountDownTimer? = null lateinit var orderBean: OrderBean @@ -43,56 +46,55 @@ override fun onPause() { super.onPause() - if (time != null){ + if (time != null) { time!!.cancel() } } override fun setBlackMode(b: Boolean?) { super.setBlackMode(b) - if(b!!){ //晚上 + if (b!!) { //晚上 rl_main_bg.setBackgroundResource(R.color.black) ll_content_web.setBackgroundResource(R.drawable.bg_slab_main_8_black) ll_order_top.setBackgroundResource(R.drawable.bg_slab_main_8_black_bottom) // ll_pay_result.setBackgroundResource(R.drawable.bg_slab_main_8_shen_black) iv_back_slab.setImageResource(R.mipmap.icon_back_slab) - tv_title_slab.textColor(this,R.color.write) - tv_name.textColor(this,R.color.write) - tv_car_num.textColor(this,R.color.write) - tv_phone.textColor(this,R.color.write) - tv_time.textColor(this,R.color.write) + tv_title_slab.textColor(this, R.color.write) + tv_name.textColor(this, R.color.write) + tv_car_num.textColor(this, R.color.write) + tv_phone.textColor(this, R.color.write) + tv_time.textColor(this, R.color.write) tv_time.setDrawableLeft(R.mipmap.icon_time_gray) - tv_start_address.textColor(this,R.color.write) - tv_end_address.textColor(this,R.color.write) - tv_red_money.textColor(this,R.color.write) - tv_pay_result_title.textColor(this,R.color.write) - tv_order_type.textColor(this,R.color.write) - tv_hive_small_money.textColor(this,R.color.write) + tv_start_address.textColor(this, R.color.write) + tv_end_address.textColor(this, R.color.write) + tv_red_money.textColor(this, R.color.write) + tv_pay_result_title.textColor(this, R.color.write) + tv_order_type.textColor(this, R.color.write) + tv_hive_small_money.textColor(this, R.color.write) tv_phone.setDrawableLeft(R.mipmap.icon_dial_slab) - }else{ + } else { rl_main_bg.setBackgroundResource(R.color.write) ll_content_web.setBackgroundResource(R.drawable.write_top_10) ll_order_top.setBackgroundResource(R.drawable.write_bottom_10) // ll_pay_result.setBackgroundResource(R.drawable.bg_white_round5) iv_back_slab.setImageResource(R.mipmap.icon_back_black) - tv_title_slab.textColor(this,R.color.black) - tv_name.textColor(this,R.color.black) - tv_car_num.textColor(this,R.color.black) - tv_phone.textColor(this,R.color.black) - tv_time.textColor(this,R.color.black) + tv_title_slab.textColor(this, R.color.black) + tv_name.textColor(this, R.color.black) + tv_car_num.textColor(this, R.color.black) + tv_phone.textColor(this, R.color.black) + tv_time.textColor(this, R.color.black) tv_time.setDrawableLeft(R.mipmap.icon_time_xiao) - tv_start_address.textColor(this,R.color.black) - tv_end_address.textColor(this,R.color.black) - tv_red_money.textColor(this,R.color.black) - tv_pay_result_title.textColor(this,R.color.black) - tv_order_type.textColor(this,R.color.black) - tv_hive_small_money.textColor(this,R.color.black) + tv_start_address.textColor(this, R.color.black) + tv_end_address.textColor(this, R.color.black) + tv_red_money.textColor(this, R.color.black) + tv_pay_result_title.textColor(this, R.color.black) + tv_order_type.textColor(this, R.color.black) + tv_hive_small_money.textColor(this, R.color.black) tv_phone.setDrawableLeft(R.mipmap.icon_dial) } } override fun initView() { - var map = getMapByAny() map["orderId"] = orderId map["orderType"] = orderType @@ -104,11 +106,29 @@ } } + + private fun showUi(orderBean: OrderBean?) { orderBean?.let { + MyApplication.getTTsManager() + .setVideoText("请确认乘客车内付款后,再点击返回首页") + time = timeOver(60000 * 6) { + tv_title_slab.text = "待支付($it)" + if (it == 0) { + if (time != null) { + time!!.cancel() + } + try { + finish() + } catch (e: Exception) { + } + } + } tv_title_slab.text = "待支付" tv_name.text = it.data.nickName tv_car_num.text = it.data.historyNum.toString() + "次乘车" + tv_phone.text = it.data.phone + tv_phone.clickDelay { MyUtils.getInstans().CallPhone(this, it.data.phone.toString()) } @@ -117,6 +137,7 @@ tv_time.text = it.data.travelTime tv_start_address.text = it.data.startAddress tv_end_address.text = it.data.endAddress + tv_end_address.visibility = if (it.data.endAddress.isNullOrEmpty()) View.GONE else View.VISIBLE tv_red_money.text = it.data.tipMoney.toString() + "元小费" // when (orderBean.data.orderState) { // 10, 11 -> { @@ -144,51 +165,14 @@ } } - private fun addSocketLisener(orderBean: OrderBean?) { - MyApplication.addOrderView(object : MyApplication.OrderStatueView { - override fun orderInfo(data: OrderSimpleData?) { - data?.let { - if (it.status == 8||it.status == 7) { - tv_pay_result_money.textColor( - this@SlabOrderOverActivity, - R.color.slab_green_over - ) - Handler(Looper.getMainLooper()).post { - if (isPlay) - { - return@post - } - isPlay = true - MyApplication.getTTsManager().setVideoText("乘客已支付"+orderBean?.data?.orderMoney.toString()+"元") - time = timeOver(20000) { - tv_title_slab.text = "已完成($it)" - if (it == 0) { - if (time != null) { - time!!.cancel() - } - try { - onBackPressed() - } catch (e: Exception) { - } - } - } - } - -// android.os.Handler(Looper.getMainLooper()).post { -// orderBean.data.orderState = 8 -// showUi(orderBean) -// } - } - } + fun overOrder(){ + callComplete() { + Handler(Looper.getMainLooper()).post { + time?.cancel() + time?.onFinish() + finish() } - }) - -// if (handler == null) { -// handler = android.os.Handler(mainLooper) -// handler!!.postDelayed({ -// checkOrderStatue() -// }, 3000) -// } + } } var handler: Handler? = null @@ -204,20 +188,20 @@ var map = getMapByAny() // map["orderId"] = orderId // map["orderType"] = orderType - callNet(false,Api.orderStateSocket, map) { + callNet(false, Api.orderStateSocket, map) { val orderSimpleData = Gson().fromJson( it, OrderStatueBean::class.java ) orderSimpleData?.data?.let { - var currentBean:OrderStatueBean.DataBean? = null - for (item in it){ - if (item.orderId ==orderBean.data?.orderId ){ + var currentBean: OrderStatueBean.DataBean? = null + for (item in it) { + if (item.orderId == orderBean.data?.orderId) { currentBean = item } } - if (it.size == 0 || currentBean == null){ + if (it.size == 0 || currentBean == null) { return@callNet } if (currentBean.state == 8) { @@ -226,12 +210,15 @@ R.color.slab_green_over ) Handler(Looper.getMainLooper()).post { - if (isPlay) - { + if (isPlay) { return@post } isPlay = true - MyApplication.getTTsManager().setVideoText("乘客已支付"+ orderBean.data?.orderMoney.toString()+"元") + tv_complete.gone() + tv_to_main.visible() + MyApplication.getTTsManager() + .setVideoText("乘客已支付" + orderBean.data?.orderMoney.toString() + "元") + time?.cancel() time = timeOver(20000) { tv_title_slab.text = "已完成($it)" if (it == 0) { @@ -239,7 +226,7 @@ time!!.cancel() } try { - onBackPressed() + finish() } catch (e: Exception) { } } @@ -282,5 +269,81 @@ tv_to_main.clickDelay { onBackPressed() } + + tv_complete.clickDelay { + var pop = DialogUtil.getSlabDelAndSurePopWindow(this,"请确认是否收到乘客线下付款",{}){ + overOrder() + } + pop.contentView.tv_close_base.text = "未收款" + pop.contentView.tv_sure_base.text = "已收款" + pop.showCenter(window.decorView) + + } } + + override fun onBackPressed() { + overOrder() + } + + private fun callComplete(function: () -> Unit) { + var map = getMapByAny() + map["orderId"] = orderId + map["orderType"] = orderType + callNet(Api.completeOrder,map,{ + function() + }){ + function() + } + } + + + + private fun addSocketLisener(orderBean: OrderBean?) { + MyApplication.addOrderView(object : MyApplication.OrderStatueView { + override fun orderInfo(data: OrderSimpleData?) { + data?.let { + if (it.status == 8 || it.status == 7) { + tv_pay_result_money.textColor( + this@SlabOrderOverActivity, + R.color.slab_green_over + ) + Handler(Looper.getMainLooper()).post { + if (isPlay) { + return@post + } + isPlay = true + MyApplication.getTTsManager() + .setVideoText("乘客已支付" + orderBean?.data?.orderMoney.toString() + "元") + time = timeOver(20000) { + tv_title_slab.text = "已完成($it)" + if (it == 0) { + if (time != null) { + time!!.cancel() + } + try { + finish() + } catch (e: Exception) { + } + } + } + } + +// android.os.Handler(Looper.getMainLooper()).post { +// orderBean.data.orderState = 8 +// showUi(orderBean) +// } + } + } + } + }) + + +// if (handler == null) { +// handler = android.os.Handler(mainLooper) +// handler!!.postDelayed({ +// checkOrderStatue() +// }, 3000) +// } + } + } \ No newline at end of file -- Gitblit v1.7.1