| | |
| | | |
| | | 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 |
| | |
| | | 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 |
| | |
| | | mMapView.map |
| | | } |
| | | private val app by lazy { |
| | | application as OkApplication |
| | | application as KuanzhaiApplication |
| | | } |
| | | private val handler by lazy { |
| | | Handler(this) |
| | |
| | | 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() |
| | | } |
| | | }) |
| | |
| | | } |
| | | |
| | | iv_location.setOnClickListener { |
| | | aMap.animateCamera(CameraUpdateFactory.newLatLngZoom(LatLng(OkApplication.lat,OkApplication.lon),15f)) |
| | | aMap.animateCamera(CameraUpdateFactory.newLatLngZoom(LatLng(KuanzhaiApplication.lat,KuanzhaiApplication.lon),15f)) |
| | | } |
| | | } |
| | | |
| | |
| | | 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) |
| | |
| | | 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) |
| | |
| | | */ |
| | | 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 = "等待接驾" |
| | |
| | | * 获取行程中的数据:主要是司机位置,订单状态变化,距离、时间等预算信息 |
| | | */ |
| | | private fun getTrippingData(){ |
| | | OkApplication.intervalCount = 0 |
| | | KuanzhaiApplication.intervalCount = 0 |
| | | HttpManager.trippingInfo(id,type).request(this){_,data-> |
| | | data?.let { |
| | | if (it.lat.isNotEmpty()) |
| | |
| | | * 获取是否有司机接单 |
| | | */ |
| | | private fun queryEndPush(){ |
| | | OkApplication.intervalCount = 0 |
| | | KuanzhaiApplication.intervalCount = 0 |
| | | HttpManager.queryEndPush(id,type).request(this){_,data-> |
| | | data?.let { |
| | | if (it.state == 2){ //无人接单 |
| | |
| | | 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) |
| | | } |
| | | } |
| | |
| | | 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) |