From a141213b3234d2d83ffb6a5d2d42ede0e722d949 Mon Sep 17 00:00:00 2001 From: lmw <125975490@qq.com> Date: 星期二, 13 六月 2023 11:57:21 +0800 Subject: [PATCH] 公务出行开发完成 --- app/src/main/java/com/kuanzhai/user/ui/trip/TripActivity.kt | 75 +++++++++++++++++++++++++------------ 1 files changed, 50 insertions(+), 25 deletions(-) diff --git a/app/src/main/java/com/kuanzhai/user/ui/trip/TripActivity.kt b/app/src/main/java/com/kuanzhai/user/ui/trip/TripActivity.kt index f9d5a88..0100143 100644 --- a/app/src/main/java/com/kuanzhai/user/ui/trip/TripActivity.kt +++ b/app/src/main/java/com/kuanzhai/user/ui/trip/TripActivity.kt @@ -2,7 +2,6 @@ import android.app.Activity import android.content.Intent -import android.content.res.Resources import android.graphics.Color import android.os.Bundle import android.os.Handler @@ -27,7 +26,7 @@ import com.amap.api.services.core.LatLonPoint import com.amap.api.services.route.* import com.google.android.material.bottomsheet.BottomSheetBehavior -import com.kuanzhai.user.OkApplication +import com.kuanzhai.user.KuanzhaiApplication import com.kuanzhai.user.R import com.kuanzhai.user.interfaces.OrderStateChangeListener import com.kuanzhai.user.network.Apis @@ -60,7 +59,7 @@ mMapView.map } private val app by lazy { - application as OkApplication + application as KuanzhaiApplication } private val handler by lazy { Handler(this) @@ -139,8 +138,8 @@ shareDialog.setCallback(object :ShareDialog.Callback{ override fun onOk(way: Int) { ShareUtils.share(this@TripActivity,if (way == 0) SHARE_MEDIA.WEIXIN else if (way == 1) SHARE_MEDIA.QQ else - SHARE_MEDIA.MORE, String.format(Const.Share.TRIP_CONTENT,OkApplication.phone,if (type == 1) "快车/专车" else "出租车",order!!.licensePlate), - Const.Share.TITLE,String.format(Apis.TRIP_URL,id,type),this@TripActivity,OkApplication.emergency) + SHARE_MEDIA.MORE, String.format(Const.Share.TRIP_CONTENT,KuanzhaiApplication.phone,if (type == 1) "快车/专车" else "出租车",order!!.licensePlate), + Const.Share.TITLE,String.format(Apis.TRIP_URL,id,type),this@TripActivity,KuanzhaiApplication.emergency) shareDialog.dismiss() } }) @@ -152,7 +151,7 @@ } iv_location.setOnClickListener { - aMap.animateCamera(CameraUpdateFactory.newLatLngZoom(LatLng(OkApplication.lat,OkApplication.lon),15f)) + aMap.animateCamera(CameraUpdateFactory.newLatLngZoom(LatLng(KuanzhaiApplication.lat,KuanzhaiApplication.lon),15f)) } } @@ -236,12 +235,12 @@ aMap.uiSettings.isRotateGesturesEnabled = false aMap.uiSettings.isTiltGesturesEnabled = false aMap.isMyLocationEnabled = true - aMap.moveCamera(CameraUpdateFactory.newLatLng(LatLng(OkApplication.lat,OkApplication.lon))) + aMap.moveCamera(CameraUpdateFactory.newLatLng(LatLng(KuanzhaiApplication.lat,KuanzhaiApplication.lon))) } private fun getPhone(){ - HttpManager.getPhone(OkApplication.chooseCityCode).request(this,false){_,data-> + HttpManager.getPhone(KuanzhaiApplication.chooseCityCode).request(this,false){ _, data-> data?.let { it.forEach { if (it.type == 1) @@ -272,6 +271,10 @@ tv_passenger_num.text = String.format("%d人 座位:%s号",it.peopleNumber,it.seatNumber).replace(",","号,") tv_remark.visibility = if (it.remark.isNotEmpty()) View.VISIBLE else View.GONE tv_remark.text = it.remark + } + if (type == Const.OrderType.TYPE_OFFICIAL){ + tv_passenger_num.visible() + tv_passenger_num.text = String.format("%d人",it.peopleNumber) } if (it.state !=1){ //有司机 handler.removeMessages(0) @@ -305,14 +308,36 @@ */ private fun setStateUI(){ order?.let { + fl_official_check.gone() when(it.state){ 1->{ - title = "等待应答" - if (!handler.hasMessages(0)) - handler.sendEmptyMessage(0) - tv_action.visible() - aMap.animateCamera(CameraUpdateFactory.newLatLngZoom(LatLng(it.startLat,it.startLon),15f)) - queryEndPush() + when(it.auditStatus){ + 0->{ + title = "等待审核" + fl_official_check.visibility = View.VISIBLE + tv_action.visible() + } + 2->{ + fl_official_check.visibility = View.VISIBLE + title = "审核失败" + tv_action.gone() + tv_check_state.text = "审核失败" + tv_check_tip.text = it.auditRemark + } + -2->{ + startActivity<OrderDetailActivity>("id" to id,"type" to type) + finish() + } + else->{ + fl_official_check.gone() + title = "等待应答" + if (!handler.hasMessages(0)) + handler.sendEmptyMessage(0) + tv_action.visible() + aMap.animateCamera(CameraUpdateFactory.newLatLngZoom(LatLng(it.startLat,it.startLon),15f)) + queryEndPush() + } + } } 2->{ title = "等待接驾" @@ -411,7 +436,7 @@ * 获取行程中的数据:主要是司机位置,订单状态变化,距离、时间等预算信息 */ private fun getTrippingData(){ - OkApplication.intervalCount = 0 + KuanzhaiApplication.intervalCount = 0 HttpManager.trippingInfo(id,type).request(this){_,data-> data?.let { if (it.lat.isNotEmpty()) @@ -429,7 +454,7 @@ * 获取是否有司机接单 */ private fun queryEndPush(){ - OkApplication.intervalCount = 0 + KuanzhaiApplication.intervalCount = 0 HttpManager.queryEndPush(id,type).request(this){_,data-> data?.let { if (it.state == 2){ //无人接单 @@ -632,12 +657,12 @@ val c = String.format("正为您寻找车辆 等待%02d:%02d", i / 1000 / 60, i / 1000 % 60) setMarker(latLon, SpanBuilder(c) .color(this,10,c.length,R.color.colorRed).build()) - OkApplication.intervalCount ++ - if (OkApplication.intervalCount>7){ + KuanzhaiApplication.intervalCount ++ + if (KuanzhaiApplication.intervalCount>7){ queryEndPush() getTrippingData() } - Log.e("timer","事件0:"+OkApplication.intervalCount) + Log.e("timer","事件0:"+KuanzhaiApplication.intervalCount) handler.sendEmptyMessageDelayed(0, 1000) } } @@ -649,20 +674,20 @@ val c = String.format("司机到达预约地点,已等您%02d:%02d", i / 1000 / 60, i / 1000 % 60) tv_state.text = SpanBuilder(c).color(this,12,c.length,R.color.colorOrange).build() tv_state_pin.text = SpanBuilder(c).color(this,12,c.length,R.color.colorOrange).build() - OkApplication.intervalCount ++ - if (OkApplication.intervalCount>7){ + KuanzhaiApplication.intervalCount ++ + if (KuanzhaiApplication.intervalCount>7){ getTrippingData() } - Log.e("timer","事件1:"+OkApplication.intervalCount) + Log.e("timer","事件1:"+KuanzhaiApplication.intervalCount) handler.sendEmptyMessageDelayed(1, 1000) } } 2->{ - OkApplication.intervalCount ++ - if (OkApplication.intervalCount>7){ + KuanzhaiApplication.intervalCount ++ + if (KuanzhaiApplication.intervalCount>7){ getTrippingData() } - Log.e("timer","事件2:"+OkApplication.intervalCount) + Log.e("timer","事件2:"+KuanzhaiApplication.intervalCount) if (order?.state == 2) fl_reserve.visibility = if (order!!.travelTime1.isNotEmpty()&&order!!.travelTime1.parserTime()-System.currentTimeMillis()>(30L*60*1000)) View.VISIBLE else View.GONE handler.sendEmptyMessageDelayed(2, 1000) -- Gitblit v1.7.1