From d2c92897e22b2c1992eceaef585f967a06b6ea84 Mon Sep 17 00:00:00 2001 From: liugl <liugl@sinata.cn> Date: 星期一, 02 十一月 2020 15:59:29 +0800 Subject: [PATCH] 11.30 首页列表添加 其他数据用来展示页面 不空 --- app/src/main/java/com/okgoincar/slab/SlabOrderOverActivity.kt | 182 ++++++++++++++++++++++++++++++++++----------- 1 files changed, 137 insertions(+), 45 deletions(-) diff --git a/app/src/main/java/com/okgoincar/slab/SlabOrderOverActivity.kt b/app/src/main/java/com/okgoincar/slab/SlabOrderOverActivity.kt index d659f30..c7b5512 100644 --- a/app/src/main/java/com/okgoincar/slab/SlabOrderOverActivity.kt +++ b/app/src/main/java/com/okgoincar/slab/SlabOrderOverActivity.kt @@ -11,6 +11,7 @@ import com.okgoincar.base.MyApplication import com.okgoincar.bean.OrderBean import com.okgoincar.bean.OrderSimpleData +import com.okgoincar.bean.OrderStatueBean import com.okgoincar.netUtls.Api import com.okgoincar.netUtls.timeOver import com.okgoincar.utils.MyUtils @@ -27,7 +28,7 @@ intent.getStringExtra("orderId") } - var time:CountDownTimer? = null + var time: CountDownTimer? = null lateinit var orderBean: OrderBean @@ -42,50 +43,50 @@ 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) } } @@ -98,8 +99,8 @@ callNet(this, Api.queryOrderInfo, map) { orderBean = gson.fromJson(it, OrderBean::class.java) showUi(orderBean) - addSocketLisener() - +// addSocketLisener(orderBean) + checkOrderStatue() } } @@ -108,6 +109,7 @@ 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()) } @@ -143,22 +145,31 @@ } } - private fun addSocketLisener() { + 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) + 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 (20000){ + 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){ + if (it == 0) { + if (time != null) { time!!.cancel() } try { onBackPressed() - }catch (e:Exception){ + } catch (e: Exception) { } } } @@ -181,26 +192,65 @@ // } } - var handler: android.os.Handler? = null + var handler: Handler? = null + var isPlay = false 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) { +// map["orderId"] = orderId +// map["orderType"] = orderType + callNet(false, Api.orderStateSocket, map) { val orderSimpleData = Gson().fromJson( it, - OrderSimpleData::class.java + OrderStatueBean::class.java ) - orderSimpleData?.let { - if (orderSimpleData.status == 8) { - orderBean.data.orderState = 8 - showUi(orderBean) + orderSimpleData?.data?.let { + var currentBean: OrderStatueBean.DataBean? = null + for (item in it) { + if (item.orderId == orderBean.data?.orderId) { + currentBean = item + } + } + if (it.size == 0 || currentBean == null) { + return@callNet + } + if (currentBean.state == 8) { + tv_pay_result_money.textColor( + this@SlabOrderOverActivity, + R.color.slab_green_over + ) + Handler(Looper.getMainLooper()).post { + if (isPlay) { + return@post + } + isPlay = true + tv_complete.gone() + tv_to_main.visible() + 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) { + } + } + } + } } } } - handler?.postDelayed({ checkOrderStatue() }, 3000) } override fun onDestroy() { @@ -235,5 +285,47 @@ tv_to_main.clickDelay { onBackPressed() } + + tv_complete.clickDelay { + callComplete() { + tv_complete.gone() + tv_to_main.visible() + 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) { + } + } + } + } + } + } + } + + private fun callComplete(function: () -> Unit) { + var map = getMapByAny() + map["orderId"] = orderId + map["orderType"] = orderType + callNet(Api.completeOrder,map,{ + function() + }){ + + } } } \ No newline at end of file -- Gitblit v1.7.1