| | |
| | | import android.content.Intent |
| | | import android.content.pm.PackageManager |
| | | import android.graphics.Bitmap |
| | | import android.graphics.Color |
| | | import android.os.Bundle |
| | | import android.os.Handler |
| | | import android.os.Message |
| | |
| | | import com.google.android.gms.maps.model.Marker |
| | | import com.google.android.gms.maps.model.MarkerOptions |
| | | import com.google.android.gms.maps.model.Polyline |
| | | import com.google.android.gms.maps.model.PolylineOptions |
| | | import com.google.android.libraries.mapsplatform.transportation.consumer.ConsumerApi |
| | | import com.google.android.libraries.mapsplatform.transportation.consumer.managers.TripModelCallback |
| | | import com.google.android.libraries.mapsplatform.transportation.consumer.model.MarkerType |
| | |
| | | titleBar.getRightButton(0)?.gone() |
| | | aMap?.isMyLocationEnabled = false //行程中取消乘客定位 |
| | | drawLine() |
| | | ll_receiver_goods_code.isVisible = |
| | | it.orderType == Const.OrderType.TYPE_SAME_CITY |
| | | ll_receiver_goods_code.isVisible = it.orderType == Const.OrderType.TYPE_SAME_CITY |
| | | tv_receiver_goods_code.text = getString(R.string.取件码) + (it.code ?: "") |
| | | } |
| | | |
| | |
| | | private fun drawLine() { |
| | | if (order?.orderType == 4) return // 快件订单不绘制 |
| | | if (startMarker != null && endMarker != null) { |
| | | LogHelper.logRecord("开始规划路线") |
| | | AMapKit.initRouteLine( |
| | | startMarker!!.position, |
| | | endMarker!!.position, |
| | | object : (MutableList<LatLng>, Float, Long) -> Unit { |
| | | override fun invoke(p1: MutableList<LatLng>, p2: Float, p3: Long) { |
| | | if (isFinishing || isDestroyed) { |
| | | LogHelper.logRecord("订单行程页已经关闭") |
| | | return |
| | | } |
| | | aMap?.also { |
| | | markerLine?.remove() |
| | | LogHelper.logRecord("开始绘制规划路线 ${p1.size}") |
| | | markerLine = AMapKit.drawLine(this@TripActivity, it, p1) |
| | | AMapKit.moveCamera(it, startMarker!!.position, endMarker!!.position) |
| | | } |
| | |
| | | object : TypeToken<List<Point>>() {}.type |
| | | ) |
| | | if (!list.isNullOrEmpty()) { |
| | | oldDrivedRouteOverlay = newDrivedRouteOverlay |
| | | newDrivedRouteOverlay = drawLine(list.map { LatLng(it.lat, it.lon) }) |
| | | oldDrivedRouteOverlay?.remove() |
| | | aMap?.also { it -> |
| | | oldDrivedRouteOverlay = newDrivedRouteOverlay |
| | | val data = list.map { LatLng(it.lat, it.lon) }.toMutableList() |
| | | if (driverMarker != null) { |
| | | data.add(driverMarker!!.position) |
| | | } |
| | | newDrivedRouteOverlay = AMapKit.drawLine(this, it, data, cn.sinata.xldutils.R.color.textColor99) |
| | | oldDrivedRouteOverlay?.remove() |
| | | } |
| | | } |
| | | } catch (e: Exception) { |
| | | e.printStackTrace() |
| | |
| | | } |
| | | |
| | | /** |
| | | * 绘制已行驶灰色路径 |
| | | */ |
| | | private fun drawLine(latLngs: List<LatLng>): Polyline? { |
| | | val options = PolylineOptions().addAll(latLngs) |
| | | if (driverMarker != null) { |
| | | options.add(driverMarker!!.position) |
| | | } |
| | | options.width(20f).color(Color.parseColor("#999999")) |
| | | return aMap?.addPolyline(options) |
| | | } |
| | | |
| | | /** |
| | | * handler定时器 |
| | | * #what:0:等待应答 1:司机等待 2:其他状态时,判断socket是否在线,如果不在线就调仿socket接口 |
| | | */ |
| | |
| | | val latLon = LatLng(order!!.startLat, order!!.startLon) |
| | | val waittime = order!!.insertTime.parserTime() |
| | | val s = System.currentTimeMillis() |
| | | val i = Math.max(s - waittime, 0L) |
| | | val i = (s - waittime).coerceAtLeast(0L) |
| | | val c = getString(R.string.正在寻找车辆, i / 1000 / 60, i / 1000 % 60) |
| | | setMarker( |
| | | latLon, SpanBuilder(c) |
| | | .color(this, c.length - 6, c.length, R.color.colorRed).build() |
| | | latLon, |
| | | SpanBuilder(c).color(this, c.length - 6, c.length, R.color.colorRed).build() |
| | | ) |
| | | IGoApplication.intervalCount++ |
| | | if (IGoApplication.intervalCount > 7) { |