liugl
2021-06-21 0fb44d953ab25a53d228b4c1f9381df80e70ee03
app/src/main/java/com/okgoincar/slab/SlabTripActivity.kt
@@ -26,6 +26,7 @@
import com.okgoincar.base.AMapKit.initMap
import com.okgoincar.base.AMapKit.moveCamera
import com.okgoincar.base.BaseEvent
import com.okgoincar.base.MoneyBroadCastReceiver
import com.okgoincar.base.MyApplication
import com.okgoincar.base.gpsnav.GPSNaviActivity
import com.okgoincar.bean.OrderBean
@@ -47,45 +48,19 @@
import org.greenrobot.eventbus.EventBus
import org.jetbrains.anko.startActivity
import org.jetbrains.anko.toast
import java.lang.Exception
import java.util.concurrent.TimeUnit
class SlabTripActivity : MySlabBaseActivity() {
    private fun callOver(contexts: Context, travelFee:Double){
        if (MyApplication.currentOrderId.isEmpty()){
            cn.sinata.xldutils.utils.toast("没有进行中的订单,无法结束")
            return
        }
        var map = getMapByAny()
        map["orderId"] = MyApplication.currentOrderId
        map["orderType"] = MyApplication.currentOrderType
        map["travelFee"] = travelFee
        map["lat"] = MyApplication.getLocation().latitude
        map["lon"] = MyApplication.getLocation().longitude
        map["type"] = 1
        callNet(contexts,Api.confirmFees_,map){
            EventBus.getDefault().post(BaseEvent(BaseEvent.SURE_MONEY))
        }
    private fun callOver(contexts: Context, travelFee: Double) {
        MoneyBroadCastReceiver.callOver(contexts, travelFee)
    }
    private fun callStatue(contexts: Context, i: Int) {
        if (MyApplication.currentOrderId.isEmpty()){
            cn.sinata.xldutils.utils.toast("没有进行中的订单,无法开始")
            return
        }
        var map = getMapByAny()
        map["orderId"] = MyApplication.currentOrderId
        map["orderType"] = MyApplication.currentOrderType
        map["state"] = i
        map["lat"] = MyApplication.getLocation().latitude
        map["lon"] = MyApplication.getLocation().longitude
        callNet(contexts, Api.process, map) {
            EventBus.getDefault().post(BaseEvent(BaseEvent.UP_TRIP))
        }
        MoneyBroadCastReceiver.callStatue(contexts, i)
    }
    /***
     * //    流程操作状态(3=开始出发预约点,4=到达预约点,5=开始服务,6=服务结束)
@@ -121,47 +96,47 @@
            ll_info_top.setBackgroundResource(R.drawable.bg_slab_main_8_black)
            rl_back.setBackgroundResource(R.color.black_191919)
            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_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_phone.setDrawableLeft(R.mipmap.icon_dial_slab)
            tv_time.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_end_address.textColor(this,R.color.write)
            tv_time.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_end_address.textColor(this, R.color.write)
            tv_code_num.textColor(this,R.color.write)
            tv_name_car_man.textColor(this,R.color.write)
            tv_car_num_var.textColor(this,R.color.write)
            tv_star_num.textColor(this,R.color.write)
            tv_company.textColor(this,R.color.write)
            tv_time_send_prove.textColor(this,R.color.write)
            tv_current_time.textColor(this,R.color.write)
            tv_code_num.textColor(this, R.color.write)
            tv_name_car_man.textColor(this, R.color.write)
            tv_car_num_var.textColor(this, R.color.write)
            tv_star_num.textColor(this, R.color.write)
            tv_company.textColor(this, R.color.write)
            tv_time_send_prove.textColor(this, R.color.write)
            tv_current_time.textColor(this, R.color.write)
        } else {
            ll_order_top.setBackgroundResource(R.drawable.write_bottom_10)
            ll_info_top.setBackgroundResource(R.drawable.write_top_10)
            rl_back.setBackgroundResource(R.drawable.write)
            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_phone.setDrawableNull()
            tv_time.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_end_address.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_phone.setDrawableLeft(R.mipmap.car_phone_bkack)
            tv_time.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_end_address.textColor(this, R.color.black)
            tv_code_num.textColor(this,R.color.black)
            tv_name_car_man.textColor(this,R.color.black)
            tv_car_num_var.textColor(this,R.color.black)
            tv_star_num.textColor(this,R.color.black)
            tv_company.textColor(this,R.color.black)
            tv_time_send_prove.textColor(this,R.color.black)
            tv_current_time.textColor(this,R.color.black)
            tv_code_num.textColor(this, R.color.black)
            tv_name_car_man.textColor(this, R.color.black)
            tv_car_num_var.textColor(this, R.color.black)
            tv_star_num.textColor(this, R.color.black)
            tv_company.textColor(this, R.color.black)
            tv_time_send_prove.textColor(this, R.color.black)
            tv_current_time.textColor(this, R.color.black)
        }
    }
@@ -186,6 +161,7 @@
                    if (it.status == 10 || it.status == 12) {
                        Handler(Looper.getMainLooper()).post {
                            toast("用户已取消订单")
                            MyApplication.getTTsManager().setVideoText("用户已取消订单")
                            MyApplication.currentOrderType = ""
                            MyApplication.currentOrderId = ""
                            finish()
@@ -200,7 +176,7 @@
        super.onBackPressed()
    }
    fun changeMode(){
    fun changeMode() {
        if (tv_change.text == "收起") {
            rl_map.invisible()
            rl_persion_info.visible()
@@ -217,18 +193,17 @@
    }
    private fun onclick() {
        btn_start.clickDelay {
            callStatue(this,5)
            callStatue(this, 5)
        }
        btn_end.clickDelay {
            callOver(this,10.0)
            callOver(this, 10.0)
        }
        tv_change.clickDelay {
          changeMode()
            changeMode()
        }
        iv_move.setOnClickListener {
            orderBean.let {
@@ -240,7 +215,11 @@
                        moveCamera(aMap, carMarker!!.position)
                    }
                    5, 6 -> {
                        moveCamera(aMap, carMarker!!.position, endMarker!!.position)
                        if (endMarker == null){
                            moveCamera(aMap, carMarker!!.position)
                        }else{
                            moveCamera(aMap, carMarker!!.position, endMarker!!.position)
                        }
                    }
                }
            }
@@ -257,11 +236,18 @@
                    }
                    5, 6 -> {
//                        startAMapNavi(endMarker!!)
                        startActivity<GPSNaviActivity>(
                            "start" to carMarker!!.position,
                            "end" to endMarker!!.position
                        )
                        if (endMarker == null){
                            toast("暂无终点")
                        }else{
                            startActivity<GPSNaviActivity>(
                                "start" to carMarker!!.position,
                                "end" to endMarker!!.position
                            )
                        }
                    }
                    else -> {
                    }
                }
            }
@@ -320,12 +306,12 @@
        var payType = 1 //支付方式(1=OK平台收款,2=其他方式收款)
        if (getNowTimeBlack()) {
            pop.contentView.rl_back_pop.setBackgroundResource(R.drawable.bg_slab_main_8_black)
            pop.contentView.tv_cancel.textColor(this,R.color.white)
            pop.contentView.tv_ok.textColor(this,R.color.white)
            pop.contentView.tv_cancel.textColor(this, R.color.white)
            pop.contentView.tv_ok.textColor(this, R.color.white)
        } else {
            pop.contentView.rl_back_pop.setBackgroundResource(R.drawable.bg_white_round_2)
            pop.contentView.tv_cancel.textColor(this,R.color.black)
            pop.contentView.tv_ok.textColor(this,R.color.black)
            pop.contentView.tv_cancel.textColor(this, R.color.black)
            pop.contentView.tv_ok.textColor(this, R.color.black)
        }
        pop.showDown(window.decorView)
        pop.contentView.tv_cancel.setOnClickListener {
@@ -360,10 +346,10 @@
                })
                if (getNowTimeBlack()) {
                    pop.contentView.rl_top_slab.setBackgroundResource(R.drawable.bg_green_4_black)
                    pop.contentView.tv_view_two_base.textColor(this,R.color.white)
                    pop.contentView.tv_view_two_base.textColor(this, R.color.white)
                } else {
                    pop.contentView.rl_top_slab.setBackgroundResource(R.drawable.bg_white_round_2)
                    pop.contentView.tv_view_two_base.textColor(this,R.color.black)
                    pop.contentView.tv_view_two_base.textColor(this, R.color.black)
                }
                pop.showCenter(window.decorView)
            }
@@ -391,8 +377,11 @@
    private fun initMineLocation() {
        AMapKit.initLocation(this, AMapLocationListener {
            it?.let {
                MyApplication.aMapLocation = it
                carMarker!!.position = LatLng(it.latitude, it.longitude)
//                toast("errorCode=="+it.errorCode.toString()+"latitude=="+it.latitude.toString())
                if (it.errorCode == 0) {
                    MyApplication.aMapLocation = it
                    carMarker!!.position = LatLng(it.latitude, it.longitude)
                }
            }
            orderBean.let {
                when (it.data.orderState) {
@@ -442,7 +431,19 @@
                        }
                    }
                })
        }else{
            var view =
                creatCarView()
            carMarker?.setIcon(getIcon(view))
            if (isMove) {
                moveCamera(aMap, carMarker!!.position)
            }
        }
    }
    fun creatNullView(): View {
        val carView = createView(R.layout.view_no, this)
        return carView
    }
@@ -472,7 +473,11 @@
    private fun showDriverUI(data: UserInfoBean?) {
        data?.let {
            tv_code_num.text = "证号:" + data.taxiAptitudeCard
            if (data.taxiAptitudeCard.length > 7){
                tv_code_num.text  = "资格证号:"+data.taxiAptitudeCard.substring(0,3)+"*******"+data.taxiAptitudeCard.substring(data.taxiAptitudeCard.length-4,data.taxiAptitudeCard.length)
            }else{
                tv_code_num.text = "资格证号:" + data.taxiAptitudeCard
            }
            tv_name_car_man.text = "姓名:" + it.name
            tv_car_num_var.text = "车牌:" + it.licensePlate
            recycler_view_start.layoutManager =
@@ -488,7 +493,7 @@
            tv_current_time.text = DateUtil.getTime(
                DateUtil.TYPE7,
                System.currentTimeMillis()
            ) + "\n" + DateUtil.getWeek(System.currentTimeMillis())
            ) +  DateUtil.getWeek(System.currentTimeMillis())
        }
    }
@@ -499,6 +504,7 @@
            tv_time.text = it.data.travelTime
            tv_start_address.text = it.data.startAddress
            tv_end_address.text = it.data.endAddress
            tv_end_address.visibility = if (it.data.endAddress.isNullOrEmpty()) View.GONE else View.VISIBLE
            tv_red_money.text = it.data.tipMoney.toString() + "元小费"
            tv_phone.text = orderBean.data.phone
            showStatueMapUI(it)
@@ -523,7 +529,7 @@
            view.iv_img.setImageResource(R.mipmap.zhongdian)
            endMarker = addMarker(aMap, it.data.endLat, it.data.endLon, view, "")
        }
        endMarker!!.isVisible = false
        endMarker?.isVisible = false
        if (carMarker == null) {
            val carView = creatCarView("")
            carMarker = addMarker(
@@ -552,12 +558,18 @@
        return carView
    }
    fun creatCarView(): View {
        val carView = createView(R.layout.item_map_market, this)
        carView.iv_img.setImageResource(R.mipmap.icon_car)
        carView.tv_hint.gone()
        return carView
    }
    //    流程操作状态(3=开始出发预约点,4=到达预约点,5=开始服务,6=服务结束)
    private fun showStatueMapUI(it: OrderBean) {
        getAllMark(it)
        when (it.data.orderState) {
            2, 3 -> {
                toast("点亮网约")
                clickBroad()
                iv_to_gd.visible()
                makeMarker?.isVisible = true
@@ -573,7 +585,6 @@
                }
            }
            4 -> {
                toast("点亮网约")
                clickBroad()
                iv_to_gd.gone()
                closeLine()
@@ -603,11 +614,11 @@
        }
    }
    fun clickBroad(){
        var intent =  Intent();
    fun clickBroad() {
        var intent = Intent();
        intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK;
        intent.action = "wisdom.intent.action.topLight";
        intent.putExtra("state",0)
        intent.putExtra("state", 0)
        sendBroadcast(intent);
    }
@@ -662,17 +673,6 @@
        }
    }
    fun getTance(startLatLng: LatLng, endLatLng: LatLng, onclick: (tance: Float) -> Unit) {
        AMapKit.initRouteLine(
            this,
            startLatLng,
            endLatLng,
            object : (MutableList<LatLng>, Float, Long) -> Unit {
                override fun invoke(p1: MutableList<LatLng>, p2: Float, p3: Long) {
                    onclick(p2)
                }
            })
    }
    override fun setOnclick() {
@@ -687,19 +687,25 @@
    override fun onEventMainThread(event: BaseEvent?) {
        super.onEventMainThread(event)
        when (event!!.code) {
            BaseEvent.REAGASSIGN_SUCCESS -> {
                MyApplication.currentOrderId = ""
                MyApplication.currentOrderType = ""
                finish()
            }
            BaseEvent.UP_TRIP ->{
//            BaseEvent.REAGASSIGN_SUCCESS -> {
//                MyApplication.currentOrderId = ""
//                MyApplication.currentOrderType = ""
//                finish()
//            }
            BaseEvent.UP_TRIP -> {
                callOrder()
            }
            BaseEvent.SURE_MONEY -> {
                startActivity<SlabOrderOverActivity>("orderId" to orderBean.data.orderId.toString() , "orderType" to "2")
                startActivity<SlabOrderOverActivity>(
                    "orderId" to orderBean.data.orderId.toString(),
                    "orderType" to "2"
                )
                finish()
            }
            BaseEvent.ERROR_INFO -> {
                onBackPressed()
            }
        }
    }
}