lmw
2023-05-27 ff365ff4346d220edf2ec1d0041f2284befe3870
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
package com.fanghua.driver.ui.main
 
import android.content.Intent
import android.os.Bundle
import android.os.CountDownTimer
import android.os.Handler
import android.os.Looper
import cn.sinata.xldutils.utils.*
import com.amap.api.maps.AMap
import com.amap.api.maps.model.*
import com.amap.api.navi.AmapNaviPage
import com.amap.api.navi.AmapNaviParams
import com.amap.api.navi.AmapNaviType
import com.amap.api.navi.AmapPageType
import com.google.gson.Gson
import com.fanghua.driver.R
import com.fanghua.driver.base.BaseEvent
import com.fanghua.driver.base.MyApplication
import com.fanghua.driver.base.MyBaseActivity
import com.fanghua.driver.base.gaode.AMapKit
import com.fanghua.driver.base.gaode.AMapKit.addMarker
import com.fanghua.driver.base.gaode.AMapKit.initMap
import com.fanghua.driver.base.gaode.AMapKit.moveCamera
import com.fanghua.driver.netUtls.*
import com.fanghua.driver.ui.DialogUtil
import com.fanghua.driver.bean.*
import com.fanghua.driver.bean.BaseBean
import com.fanghua.driver.ui.main.add_order.SearchSiteActivity
import com.fanghua.driver.ui.main.major.MajorSureMoneyActivity
import com.fanghua.driver.utils.checkPermission
import kotlinx.android.synthetic.main.activity_trip.*
import kotlinx.android.synthetic.main.layout_maker_text.view.*
import kotlinx.android.synthetic.main.layout_start_maker.view.*
import kotlinx.android.synthetic.main.layout_start_maker.view.tv_info
import org.greenrobot.eventbus.EventBus
import org.jetbrains.anko.startActivity
import org.jetbrains.anko.startActivityForResult
import org.jetbrains.anko.toast
 
 
class TripActivity : MyBaseActivity() {
 
    /***
     * //    流程操作状态(3=开始出发预约点,4=到达预约点,5=开始服务,6=服务结束)
     * 页面一共4个marker 1:预约地点 2:起点 3终点 4:司机点
     */
 
    private val orderId by lazy {
        intent.getStringExtra("orderId") ?: "0"
    }
    private val countDown by lazy { //抢单倒计时,不为0 则开启倒计时
        intent.getIntExtra("countDown", 0)
    }
 
    var startMarker: Marker? = null
    var endMarker: Marker? = null
    var markerLine: Polyline? = null
    lateinit var aMap: AMap
    private var orderBean: OrderBean? = null
 
    private var countDownTimer: CountDownTimer? = null//抢单倒计时(10s)
 
    private var toNavigation = false //true:105状态需要触发自动跳转导航页
 
    override fun setContentView() {
        setContentView(R.layout.activity_trip)
    }
 
    override fun initView() {
        setTitleText("芳华代驾")
        callOrder()
        addSockectCancel()
        MyApplication.getInstance()!!.initUpPoint()
    }
 
    private fun addSockectCancel() {
        MyApplication.addOrderView(object : MyApplication.OrderStatueView {
            override fun orderInfo(data: OrderSimpleData?) {
                data?.let {
                    if (it.id == orderId) {
                        if (it.status == 301) {
                            Handler(Looper.getMainLooper()).post {
                                toast("用户已取消订单")
                                MyApplication.getTTsManager().setVideoText("用户已取消订单")
                                MyApplication.currentOrderId = ""
                                MyApplication.finishRecord()
                                finish()
                            }
                        }
                        if (it.status == 401 || it.status == 105 || it.status == 104) {
//                        tv_money.text = "%.2f元".format(orderBean!!.estimatedPrice)  //todo 蒲志兵说先不实时显示费用
                            tv_length.text = "%s公里".format(it.actualMileage)
                            tv_waiting.text = "%s分钟".format(it.waitTime)
                            tv_duration.text = "%s分钟".format(it.travelTime)
                            if (it.endAddress.isNotEmpty()){
                                AmapNaviPage.getInstance().exitRouteActivity()
//                                toNavigation = true
                                callOrder()
                                MyApplication.getTTsManager().setVideoText("请注意,用户已修改终点")
                            }
                        }
                    }
                }
            }
        })
    }
 
 
    override fun onBackPressed() {
        EventBus.getDefault().post(BaseEvent(BaseEvent.UPDATA_MAIN_CAR))
        super.onBackPressed()
    }
 
    override fun finish() {
        EventBus.getDefault().post(BaseEvent(BaseEvent.UPDATA_MAIN_CAR))
        super.finish()
    }
 
 
    private fun callStatue(i: Int, click: () -> Unit, clickFail: () -> Unit) {
        var map = getMapByAny()
        map["orderId"] = orderId
        map["state"] = i
        map["endLat"] = MyApplication.getLocation().latitude
        map["endLng"] = MyApplication.getLocation().longitude
        map["endAddress"] = MyApplication.getLocation().address
        callNet(Api.process, map, {
            val bean = Gson().fromJson(it, BaseBean::class.java)
            if (bean.resultUtil.code == 10000)
                click()
            else
                clickFail()
        }) {
            clickFail()
        }
    }
 
 
    /**
     * 起点到终点规划
     */
    private fun drawLineAll() {
        if (startMarker != null && endMarker != null) {
            AMapKit.initRouteLine(
                this, true,
                startMarker!!.position,
                endMarker!!.position,
                object : (MutableList<LatLng>, Float, Long) -> Unit {
                    override fun invoke(p1: MutableList<LatLng>, p2: Float, p3: Long) {
                        addline(p1)
                    }
                })
        }
    }
 
    /**
     * 司机到起点规划
     */
    private fun drawLineStart() {
        AMapKit.initRouteLine(
            this, false,
            LatLng(MyApplication.aMapLocation!!.latitude, MyApplication.aMapLocation!!.longitude),
            startMarker!!.position,
            object : (MutableList<LatLng>, Float, Long) -> Unit {
                override fun invoke(p1: MutableList<LatLng>, p2: Float, p3: Long) {
                    addline(p1)
                    showMarker2(p2)
                }
            })
    }
 
    /**
     * 起点到司机规划
     */
    private fun drawLineStart2() {
        if (MyApplication.aMapLocation!=null)
            AMapKit.initRouteLine(
                this, false,
                startMarker!!.position,
                LatLng(MyApplication.aMapLocation!!.latitude, MyApplication.aMapLocation!!.longitude),
                object : (MutableList<LatLng>, Float, Long) -> Unit {
                    override fun invoke(p1: MutableList<LatLng>, p2: Float, p3: Long) {
                        addline(p1)
                    }
                })
    }
 
 
    private fun callOrder() {
        var map = getMapByAny()
        map["orderId"] = orderId
        callNet(Api.queryOrderInfo, map) {
            val resultUtil = gson.fromJson(it, OrderDetailBean::class.java).resultUtil
            if (resultUtil.code == 10000) {
                orderBean = resultUtil.data
                showUi()
            } else
                toast(resultUtil.msg)
        }
    }
 
    private fun showUi() {
        orderBean?.apply {
            //公共UI
            iv_avatar.setImageURI(avatar)
            tv_phone.text = StringUtils.hidePhoneNumber(userPhone)
            tv_distance.text =
                if (currentDistance > 100) "距你约%.1f公里".format(currentDistance / 1000) else "距你约%d米".format(
                    currentDistance.toInt()
                )
            tv_time.text = TimeUtils.getTripTime(createTime)
            tv_start.text = startAddress
            tv_end.text = if (endAddress.isNullOrEmpty()) "未填写" else endAddress
            tv_creator.text = getCreator()
            if (source == 1) { //用户创建
                tv_order_count.apply {
                    visible()
                    text = "下单%d次".format(orderTimes)
                }
                tv_cancel_count.apply {
                    visible()
                    text = "取消%d次".format(cancelTimes)
                }
                tv_balance.apply {
                    visible()
                    text = "余额:%.2f".format(balance)
                }
            } else {//司机或后台
                tv_order_count.gone()
                tv_cancel_count.gone()
                tv_balance.gone()
            }
        }
        showStatusUI()
    }
 
 
    /**
     * 根据不同状态显示地图标记
     */
    private fun showMarker1() {
        val view = createView(R.layout.layout_start_maker, this)
        view.tv_info.text = "%d分钟|预计接驾".format(orderBean!!.orderTimes)
        view.tv_name.text = orderBean!!.startAddress
        startMarker = addMarker(aMap, orderBean!!.startLat, orderBean!!.startLng, view)
        if (!orderBean?.endAddress.isNullOrEmpty()) {
            val view1 = createView(R.layout.layout_maker_text, this)
            val content = "%s\n全程%d公里,约行驶%s分钟".format(
                orderBean!!.endAddress,
                orderBean!!.estimatedMileage.toDouble().toInt(),
                orderBean!!.estimatedTime
            )
            view1.tv_info.text = SpanBuilder.content(content)
                .sizeSpan(orderBean!!.endAddress.length, content.length, 10)
                .colorSpan(
                    this,
                    orderBean!!.endAddress.length,
                    content.length,
                    R.color.textColorHint
                ).build()
            endMarker =
                addMarker(aMap, orderBean!!.endLat.toDouble(), orderBean!!.endLng.toDouble(), view1)
        }
    }
 
    private fun showMarker2(distance: Float) {
        val view = createView(R.layout.layout_maker_text, this)
        view.tv_info.text =
            if (distance > 100) "距预约点%.1f公里".format(distance / 1000) else "距预约点%d米".format(distance.toInt())
        view.iv_image.setImageResource(R.mipmap.start)
        if (startMarker == null)
            startMarker = addMarker(aMap, orderBean!!.startLat, orderBean!!.startLng, view)
        else {
            startMarker?.setIcon(BitmapDescriptorFactory.fromView(view))
        }
        endMarker?.remove()
    }
 
    private fun showMarker3() {
        val view = createView(R.layout.layout_maker_text, this)
        view.tv_info.gone()
        view.iv_image.setImageResource(R.mipmap.start)
        if (startMarker == null)
            startMarker = addMarker(aMap, orderBean!!.startLat, orderBean!!.startLng, view)
        else {
            startMarker?.setIcon(BitmapDescriptorFactory.fromView(view))
        }
        endMarker?.remove()
    }
 
    private fun showMarker4() {
        val view = createView(R.layout.layout_start_maker, this)
        view.ll_info.gone()
        if (startMarker == null)
            startMarker = addMarker(aMap, orderBean!!.startLat, orderBean!!.startLng, view)
        else
            startMarker?.setIcon(BitmapDescriptorFactory.fromView(view))
 
        if (!orderBean?.endAddress.isNullOrEmpty()) {
            val view1 = createView(R.layout.layout_maker_text, this)
            view1.tv_info.gone()
            if (endMarker == null)
                endMarker = addMarker(
                    aMap,
                    orderBean!!.endLat.toDouble(),
                    orderBean!!.endLng.toDouble(),
                    view1
                )
            else {
                endMarker?.setIcon(BitmapDescriptorFactory.fromView(view1))
                endMarker?.position =
                    LatLng(orderBean!!.endLat.toDouble(), orderBean!!.endLng.toDouble())
            }
        }
    }
 
 
    private fun showStatusUI() {
        iv_nav.gone()
        if (orderBean?.state ?: 0 > 101&&orderBean?.state?:0!=201) {
            MyApplication.currentOrderId = orderId
            tv_action.gone()
            slide_btn.visible()
            tv_record.visible()
            iv_record.visible()
            tv_order_count.gone()
            tv_cancel_count.gone()
            iv_call.visible()
            tv_more.visible()
        }
        if (orderBean?.state?:0 > 140&&orderBean?.state?:0!=201)
            MyApplication.startRecord()
        when (orderBean?.state) { //订单状态(101=待接单,102=已接单,103=前往预约点,104=到达预约点,105=开始服务,106=到达目的地,107=待支付,108=待评价,109=已完成,201=转单中,301=已取消,401=等待中)
            101,201 -> {
                showMarker1()
                if (countDown == 0)
                    tv_action.text = "抢单"
                else {
                    countDownTimer = object : CountDownTimer(countDown.toLong() * 1000, 1000) {
                        override fun onTick(millisUntilFinished: Long) {
                            tv_action.text = "接单(${(millisUntilFinished / 1000) + 1})"
                        }
 
                        override fun onFinish() {
                            val mapByAny = getMapByAny()
                            mapByAny["orderId"] = orderId
                            callNet(Api.rejectionOrder, mapByAny, {
                                finish()
                            }) {
                                finish()
                            }
                        }
                    }.start()
                }
                if (endMarker != null) {//有终点
                    moveCamera(aMap, startMarker!!.position, endMarker!!.position)
                    drawLineAll()
                    tv_money.text = "%.2f元".format(orderBean!!.estimatedPrice)
                    tv_length.text = "%d公里".format(orderBean!!.estimatedMileage.toDouble().toInt())
                } else {
                    line1.gone()
                    tv_length.gone()
                    tv_2.gone()
                    tv_1.text = "起步价"
                    tv_money.text = "%.2f元".format(orderBean!!.startPrice)
                    moveCamera(aMap, startMarker!!.position)
                }
            }
            102, 103 -> {
                showMarker2(orderBean!!.currentDistance.toFloat())
                line1.gone()
                tv_length.gone()
                tv_2.gone()
                if (!orderBean?.endAddress.isNullOrEmpty()) {//有终点
                    tv_money.text = "%.2f元".format(orderBean!!.estimatedPrice)
                } else {
                    tv_1.text = "起步价"
                    tv_money.text = "%.2f元".format(orderBean!!.startPrice)
                }
                if (MyApplication.aMapLocation!=null)
                    moveCamera(
                        aMap,
                        startMarker!!.position,
                        LatLng(
                            MyApplication.aMapLocation!!.latitude,
                            MyApplication.aMapLocation!!.longitude
                        )
                    )
                drawLineStart()
                if (orderBean?.state == 103) {
                    iv_nav.visible()
                    slide_btn.changeButtonText("到达预约地点")
                    countDownTimer =
                        object : CountDownTimer(24 * 60 * 60 * 1000, 5000) { //接驾途中,每5秒规划一次路径
                            override fun onTick(millisUntilFinished: Long) {
                                if (MyApplication.aMapLocation!=null)
                                    moveCamera(
                                        aMap,
                                        startMarker!!.position,
                                        LatLng(
                                            MyApplication.aMapLocation!!.latitude,
                                            MyApplication.aMapLocation!!.longitude
                                        )
                                    )
                                drawLineStart()
                            }
 
                            override fun onFinish() {
                            }
                        }.start()
                }
            }
            104 -> {
                showMarker3()
                countDownTimer?.cancel()
                slide_btn.changeButtonText("开始服务")
                line1.visible()
                tv_length.visible()
                tv_2.visible()
                line2.visible()
                tv_waiting.visible()
                tv_3.visible()
                line3.visible()
                tv_duration.visible()
                tv_4.visible()
                //菜单项显示等待按钮
                tv_wait.visible()
                divider_3.visible()
                tv_end.setCompoundDrawablesRelativeWithIntrinsicBounds(
                    R.mipmap.icon_end_point,
                    0,
                    R.mipmap.more_black,
                    0
                )
                //订单动态数据渲染
                tv_1.text = "预估费用"
                tv_money.text = "%.2f元".format(orderBean!!.estimatedPrice)
                tv_length.text = "%s公里".format(orderBean!!.actualMileage)
                tv_waiting.text = "%s分钟".format(orderBean!!.waitTime)
                tv_duration.text = "%s分钟".format(orderBean!!.travelTime)
                closeLine()
            }
            105, 401 -> {
                showMarker4()
                slide_btn.changeButtonText("到达目的地")
                line1.visible()
                tv_length.visible()
                tv_2.visible()
                line2.visible()
                tv_waiting.visible()
                tv_3.visible()
                line3.visible()
                tv_duration.visible()
                tv_4.visible()
                //菜单项只显示追加和等待按钮
                tv_cancel.gone()
                divider_1.gone()
                tv_reassignment.gone()
                divider_2.gone()
                tv_wait.visible()
                divider_3.visible()
                tv_end.setCompoundDrawablesRelativeWithIntrinsicBounds(
                    R.mipmap.icon_end_point,
                    0,
                    R.mipmap.more_black,
                    0
                )
                //订单动态数据渲染
                tv_1.text = "预估费用"
                tv_money.text = "%.2f元".format(orderBean!!.estimatedPrice)
                tv_length.text = "%s公里".format(orderBean!!.actualMileage)
                tv_waiting.text = "%s分钟".format(orderBean!!.waitTime)
                tv_duration.text = "%s分钟".format(orderBean!!.travelTime)
                if (endMarker != null) {//有终点
                    iv_nav.visible() //温秋红:有终点才显示导航按钮
                    moveCamera(aMap, startMarker!!.position, endMarker!!.position)
                    drawLineAll()
                } else {
                    if (MyApplication.aMapLocation!=null)
                        moveCamera(
                            aMap,
                            startMarker!!.position,
                            LatLng(
                                MyApplication.aMapLocation!!.latitude,
                                MyApplication.aMapLocation!!.longitude
                            )
                        )
                    drawLineStart2()
                }
                if (orderBean?.state == 401) {
                    slide_btn.changeButtonText("开始服务")
                }
                if (orderBean?.state == 105&&toNavigation) {
                    iv_nav.callOnClick()
                    toNavigation = false
                }
            }
            106, 107 -> {
                startActivity<MajorSureMoneyActivity>("orderId" to orderId)
                finish()
            }
        }
    }
 
 
    override fun onDestroy() {
        super.onDestroy()
        map_view.onDestroy()
        countDownTimer?.cancel()
    }
 
 
    private fun addline(allLine: MutableList<LatLng>) {
        closeLine()
        markerLine = AMapKit.drawLine(this, aMap, allLine)
    }
 
    fun closeLine() {
        if (markerLine != null) {
            markerLine!!.remove()
        }
    }
 
 
    override fun setOnclick() {
        tv_action.setOnClickListener {
            if (checkPermission()){
                val map = getMapByAny()
                map["orderId"] = orderId
                callNet(Api.grabOrder, map) {
                    val bean = Gson().fromJson<BaseBean>(it, BaseBean::class.java)
                    if (bean.resultUtil.code == 10000) {
                        toast(if (tv_action.text == "抢单") "抢单成功" else "接单成功")
                        countDownTimer?.cancel()
                        orderBean!!.state = 102
                        showStatusUI()
                    } else
                        toast(bean.resultUtil.msg)
                }
            }
        }
 
        tv_end.setOnClickListener {
            if (orderBean?.state ?: 0 > 103&&orderBean?.state?:0!=201)
                startActivityForResult<SearchSiteActivity>(1, "type" to "2")
        }
 
        slide_btn.onSwipeListener = {
            orderBean?.let {
                when (it.state) {//101=待接单,102=已接单,103=前往预约点,104=到达预约点,105=开始服务,106=到达目的地,107=待支付,108=待评价,109=已完成,201=转单中,301=已取消,401=等待中)
                    102, 103, 104, 105 -> {
                        callStatue(++it.state, {
                            if (it.state == 105&&!it.endLat.isNullOrEmpty())
                                toNavigation = true
                            when (it.state) {
                                104, 105 -> callOrder()
                                106 -> {
                                    MyApplication.currentOrderId = ""
                                    MyApplication.finishRecord()
                                    startActivity<MajorSureMoneyActivity>("orderId" to orderId)
                                    finish()
                                }
                                else -> showStatusUI()
                            }
                            if (it.state == 103)
                                iv_nav.callOnClick()
                        }) {
                            it.state--
                        }
                    }
                    401 -> {
                        callStatue(105, {
                            it.state = 105
                            showStatusUI()
                        }) {
                        }
                    }
                }
            }
        }
 
        tv_Right.clickDelay {
            var map = getMapByAny()
            map["orderId"] = orderId
            callNet(Api.queryReassignMoney, map) {
                val data = gson.fromJson<RessignBean>(it, RessignBean::class.java)
                if (data.data.amount.isNullOrEmpty()) {
                    startActivity<ReassignActivity>(
                        "orderId" to orderId
                    )
                } else {
                    DialogUtil.getDelAndSureDialog(
                        this,
                        "现在改派将收取" + data.data.amount + "元改派费,您是否要进行改派?",
                        {},
                        {
                            //跳转改派页面
                            startActivity<ReassignActivity>(
                                "orderId" to orderId,
                                "money" to data.data.amount.toString()
                            )
                        })
                }
 
 
            }
        }
 
 
 
        iv_move.setOnClickListener {
            moveCamera(
                aMap,
                LatLng(
                    MyApplication.aMapLocation?.latitude ?: 0.0,
                    MyApplication.aMapLocation?.longitude ?: 0.0
                )
            )
        }
 
 
        iv_nav.setOnClickListener {
            when (orderBean?.state) {
                103 -> {
                    val params = AmapNaviParams(null,null, Poi(orderBean?.startAddress,startMarker?.position!!,""),AmapNaviType.RIDE,AmapPageType.NAVI)
                    params.setBroadcastMode(applicationContext,2)
                    params.isNeedDestroyDriveManagerInstanceWhenNaviExit =  true
                    AmapNaviPage.getInstance().showRouteActivity(applicationContext, params, null)
                }
 
                105 -> {
                    val params = AmapNaviParams(null,null, Poi(orderBean?.endAddress,endMarker?.position!!,""),AmapNaviType.DRIVER,AmapPageType.NAVI)
                    params.setBroadcastMode(applicationContext,2)
                    params.isNeedDestroyDriveManagerInstanceWhenNaviExit =  true
                    AmapNaviPage.getInstance().showRouteActivity(applicationContext, params, null)
                }
            }
 
        }
 
 
        iv_call.clickDelay {
            Utils.callPhone(this, orderBean?.userPhone)
        }
 
        tv_more.clickDelay {
            tv_more.setCompoundDrawablesRelativeWithIntrinsicBounds(
                0,
                0,
                R.mipmap.icon_arrow_close,
                0
            )
            ll_pop.visible()
            bg.visible()
        }
 
        tv_cancel.clickDelay {
            startActivity<CancelActivity>("orderId" to orderId)
            closeMenu()
        }
 
        tv_add.clickDelay {
            startActivity<AddOrderActivity>()
            closeMenu()
        }
 
        tv_reassignment.clickDelay {
            val mapByAny = getMapByAny()
            callNet(Api.queryTransferOrderConfig, mapByAny) {
                val bean = Gson().fromJson(it, StringBean::class.java)
                if (bean.resultUtil.code == 10000) {
                    DialogUtil.getDelAndSureDialog(
                        this,
                        "现在改派将${bean.resultUtil.data}分钟内不能上线,您是否要进行改派?",
                        {},
                        {
                            startActivity<ReassignActivity>("orderId" to orderId)
                        })
                }
            }
            closeMenu()
        }
 
        tv_wait.clickDelay {
            callStatue(401, {
                orderBean!!.state = 401
                showStatusUI()
            }) {
            }
            closeMenu()
        }
 
        bg.clickDelay {
            closeMenu()
        }
    }
 
    private fun closeMenu() {
        tv_more.setCompoundDrawablesRelativeWithIntrinsicBounds(
            0,
            0,
            R.mipmap.icon_arrow_open_black,
            0
        )
        ll_pop.gone()
        bg.gone()
    }
 
 
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        aMap = initMap(savedInstanceState, map_view)
    }
 
    override fun onEventMainThread(event: BaseEvent?) {
        super.onEventMainThread(event)
        when (event!!.code) {
            BaseEvent.BACK_CAR_OVER -> {
                finish()
            }
        }
    }
 
    override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
        super.onActivityResult(requestCode, resultCode, data)
        if (resultCode == RESULT_OK && data != null) {
            val map = getMapByAny()
            map["orderId"] = orderId
            map["endLat"] = data.getDoubleExtra("lat", 0.0)
            map["endLng"] = data.getDoubleExtra("lon", 0.0)
            map["endAddress"] = data.getStringExtra("name")
            callNet(Api.setOrderEndAddress, map) {
                val bean = Gson().fromJson(it, BaseBean::class.java)
                if (bean.resultUtil.code == 10000) {
                    callOrder()
                } else
                    toast(bean.resultUtil.msg)
            }
        }
    }
}