| | |
| | | package com.driver.igotrip.ui.main.small_cargo |
| | | |
| | | import android.annotation.SuppressLint |
| | | import android.content.Intent |
| | | import android.os.Bundle |
| | | import android.os.Handler |
| | | import android.os.Looper |
| | |
| | | import android.widget.EditText |
| | | import android.widget.ImageView |
| | | import android.widget.TextView |
| | | import androidx.activity.result.ActivityResultLauncher |
| | | import androidx.activity.result.contract.ActivityResultContracts |
| | | import cn.sinata.rxnetty.LogHelper |
| | | import cn.sinata.xldutils.utils.* |
| | | import com.google.android.gms.maps.model.LatLng |
| | | import com.google.android.gms.maps.model.Marker |
| | | import com.driver.igotrip.R |
| | | import com.driver.igotrip.base.BaseEvent |
| | | import com.driver.igotrip.base.Const |
| | | import com.driver.igotrip.base.MyApplication |
| | | import com.driver.igotrip.base.MyBaseActivity |
| | | import com.driver.igotrip.base.OrderTimeOutManager |
| | | import com.driver.igotrip.base.gaode.AMapKit |
| | | import com.driver.igotrip.base.gaode.AMapKit.addMarker |
| | | import com.driver.igotrip.base.gaode.AMapKit.getIcon |
| | |
| | | import com.driver.igotrip.base.gaode.AMapKit.initMap |
| | | import com.driver.igotrip.base.gaode.AMapKit.moveCamera |
| | | import com.driver.igotrip.bean.* |
| | | import com.driver.igotrip.extension.extClearInvalidZero |
| | | import com.driver.igotrip.netUtls.* |
| | | import com.driver.igotrip.ui.DialogUtil |
| | | import com.driver.igotrip.ui.UiUtil |
| | | import com.driver.igotrip.ui.main.MediaOperationActivity |
| | | import com.driver.igotrip.ui.main.ReassignActivity |
| | | import com.driver.igotrip.ui.main.major.MajorSureMoneyActivity |
| | | import com.driver.igotrip.utils.DateUtil |
| | | import com.driver.igotrip.utils.MyUtils |
| | | import com.driver.igotrip.utils.view.SlidingButton |
| | | import com.google.android.gms.maps.GoogleMap |
| | | import com.google.android.gms.maps.SupportMapFragment |
| | | import com.google.android.gms.maps.model.LatLng |
| | | import com.google.android.gms.maps.model.Marker |
| | | import com.google.android.gms.maps.model.Polyline |
| | | import com.google.gson.Gson |
| | | import com.trello.rxlifecycle3.android.ActivityEvent |
| | |
| | | import io.reactivex.android.schedulers.AndroidSchedulers |
| | | import io.reactivex.disposables.Disposable |
| | | import io.reactivex.schedulers.Schedulers |
| | | |
| | | import org.greenrobot.eventbus.EventBus |
| | | import org.jetbrains.anko.find |
| | | import org.jetbrains.anko.startActivity |
| | |
| | | var graylist = arrayListOf<LatLng>() // 灰色轨迹 |
| | | var grayline: Polyline? = null |
| | | |
| | | //业务多媒体类型 |
| | | var businessMediaType: Int = 0 |
| | | |
| | | private val tv_name by lazy { find<TextView>(R.id.tv_name) } |
| | | private val tv_car_num by lazy { find<TextView>(R.id.tv_car_num) } |
| | | private val tv_people_cargo by lazy { find<TextView>(R.id.tv_people_cargo) } |
| | |
| | | private val iv_to_gd by lazy { find<View>(R.id.iv_to_gd) } |
| | | private val slide_btn by lazy { find<SlidingButton>(R.id.slide_btn) } |
| | | |
| | | //跳转另一个页面并接收返回结果启动器 |
| | | private lateinit var launcherForResult: ActivityResultLauncher<Intent> |
| | | |
| | | override fun setContentView() { |
| | | setContentView(R.layout.activity_trip_cargo) |
| | | } |
| | |
| | | onclick() |
| | | addSockectCancel() |
| | | |
| | | var language = SPUtils.getString(Const.language) |
| | | val language = SPUtils.getString(Const.language) |
| | | if (language == Const.Language.ENGLISH || language == Const.Language.FRENCH) |
| | | btn_gap_money.setTextSize(TypedValue.COMPLEX_UNIT_SP,12f) |
| | | btn_gap_money.setTextSize(TypedValue.COMPLEX_UNIT_SP, 12f) |
| | | else |
| | | btn_gap_money.setTextSize(TypedValue.COMPLEX_UNIT_SP,14f) |
| | | btn_gap_money.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14f) |
| | | LogHelper.logRecord("处理快件订单orderId:${orderId} orderType:${orderType}") |
| | | } |
| | | |
| | | override fun initView() { |
| | | launcherForResult = |
| | | registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result -> |
| | | when (businessMediaType) { |
| | | 0 -> { |
| | | if (result.resultCode == RESULT_OK && result.data != null) { |
| | | val result = result.data!!.getStringArrayListExtra("result") |
| | | showConfirmPriceDialog(result!!.joinToString(separator = ",")) |
| | | } else { |
| | | |
| | | } |
| | | |
| | | private fun addSockectCancel() { |
| | | checkOrderStatue() |
| | | MyApplication.addOrderView(object : MyApplication.OrderStatueView { |
| | | override fun orderInfo(data: OrderSimpleData?) { |
| | | data?.let { |
| | | if (it.status == 10 || it.status == 11|| it.status == 12) { |
| | | MyApplication.currentOrderType = "" |
| | | MyApplication.currentOrderId = "" |
| | | Handler(Looper.getMainLooper()).post { |
| | | finish() |
| | | } |
| | | } |
| | | if ((it.orderType == 4 || it.orderType == 5) && it.orderId.toString() == orderId && (it.status != 10 && it.status != 11&& it.status != 12)) { |
| | | Handler(Looper.getMainLooper()).post { |
| | | callOrder() {} |
| | | |
| | | 1 -> { |
| | | if (result.resultCode == RESULT_OK && result.data != null) { |
| | | val result = result.data!!.getStringArrayListExtra("result") |
| | | showConfirmDeliveryDialog(result!!.joinToString(separator = ",")) |
| | | } else { |
| | | |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }) |
| | | } |
| | | |
| | | private fun addSockectCancel() { |
| | | checkOrderStatue() |
| | | MyApplication.addOrderView(listener) |
| | | } |
| | | |
| | | private val listener = object : MyApplication.OrderStatueView { |
| | | override fun orderInfo(data: OrderSimpleData?) { |
| | | data?.let { |
| | | if (it.status == 10 || it.status == 11 || it.status == 12) { |
| | | MyApplication.currentOrderType = "" |
| | | MyApplication.currentOrderId = "" |
| | | Handler(Looper.getMainLooper()).post { |
| | | finish() |
| | | } |
| | | } |
| | | if ((it.orderType == 4 || it.orderType == 5) && it.orderId.toString() == orderId && (it.status != 10 && it.status != 11 && it.status != 12)) { |
| | | Handler(Looper.getMainLooper()).post { |
| | | callOrder() {} |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | var handler: Handler? = null |
| | | fun checkOrderStatue() { |
| | | var map = getMapByAny() |
| | | val map = getMapByAny() |
| | | map["orderId"] = orderId |
| | | map["orderType"] = orderType |
| | | callNet(false, Api.orderStateSocket, map) { |
| | | callNet(false, Api.orderStateSocket, map) { it -> |
| | | val orderSimpleData = |
| | | Gson().fromJson( |
| | | it, |
| | | OrderSimpleData::class.java |
| | | ) |
| | | orderSimpleData?.let { |
| | | if (it.status == 10||it.status == 12) { |
| | | if (it.status == 10 || it.status == 12) { |
| | | MyApplication.currentOrderType = "" |
| | | MyApplication.currentOrderId = "" |
| | | Handler(Looper.getMainLooper()).post { |
| | |
| | | |
| | | private fun onclick() { |
| | | tv_Right.clickDelay { |
| | | var map = getMapByAny() |
| | | val map = getMapByAny() |
| | | map["orderId"] = orderId |
| | | map["orderType"] = orderType |
| | | callNet(Api.queryReassignMoney, map) { |
| | | callNet(Api.queryReassignMoney, map, { |
| | | val data = gson.fromJson<RessignBean>(it, RessignBean::class.java) |
| | | LogHelper.logRecord("查询订单改派金额成功orderId:${orderId} orderType:${orderType} data:${Gson().toJson(data)}") |
| | | startActivity<ReassignActivity>( |
| | | "orderId" to orderId, |
| | | "orderType" to orderType |
| | | ) |
| | | // if (data.data.amount.isNullOrEmpty()) { |
| | | // |
| | | // } else { |
| | | // DialogUtil.getDelAndSureDialog( |
| | | // this, |
| | | // getString(R.string.change_order_hint,data.data.amount!!), |
| | | // {}, |
| | | // { |
| | | // //跳转改派页面 |
| | | // startActivity<ReassignActivity>( |
| | | // "orderId" to orderId, |
| | | // "orderType" to orderType, |
| | | // "money" to data.data.amount.toString() |
| | | // ) |
| | | // }) |
| | | // } |
| | | |
| | | |
| | | }) { code, msg -> |
| | | LogHelper.logRecord("查询订单改派金额失败orderId:${orderId} orderType:${orderType} code:${code} msg:${msg}") |
| | | } |
| | | } |
| | | |
| | |
| | | toast(getString(R.string.用户已支付差价)) |
| | | return@clickDelay |
| | | } |
| | | var dialog = DialogUtil.getDialog(this, R.layout.dialog_show_cha_money) |
| | | var viewContent = DialogUtil.getView(dialog) |
| | | val dialog = DialogUtil.getDialog(this, R.layout.dialog_show_cha_money) |
| | | val viewContent = DialogUtil.getView(dialog) |
| | | val view_hint_close_car_cha = viewContent.find<View>(R.id.view_hint_close_car_cha) |
| | | val tv_car_num_close_cha = viewContent.find<View>(R.id.tv_car_num_close_cha) |
| | | val tv_sure_car_num_cha = viewContent.find<View>(R.id.tv_sure_car_num_cha) |
| | |
| | | dialog.dismiss() |
| | | } |
| | | tv_sure_car_num_cha.setOnClickListener { |
| | | var num = et_num_zg_cha.getContent() |
| | | val num = et_num_zg_cha.getContent() |
| | | if (num.isEmpty()) { |
| | | toast(getString(R.string.请输入金额)) |
| | | return@setOnClickListener |
| | |
| | | toast(getString(R.string.金额不能小于0元)) |
| | | return@setOnClickListener |
| | | } |
| | | callseatmoney(num) { |
| | | callseatmoney(num, { |
| | | LogHelper.logRecord("补差价操作成功orderId:${orderId} orderType:${orderType}") |
| | | dialog.dismiss() |
| | | btn_gap_money.text = getString(R.string.差价待确认).format(num.toDouble()) |
| | | btn_gap_money.setCompoundDrawablesRelativeWithIntrinsicBounds(0,0,0,0) |
| | | btn_gap_money.text = |
| | | getString(R.string.差价待确认).format(num.extClearInvalidZero()) |
| | | btn_gap_money.setCompoundDrawablesRelativeWithIntrinsicBounds(0, 0, 0, 0) |
| | | // toast(getString(R.string.set_success)) |
| | | }) { code, msg -> |
| | | LogHelper.logRecord("补差价操作失败orderId:${orderId} orderType:${orderType} code:${code} msg:${msg}") |
| | | } |
| | | } |
| | | } |
| | |
| | | when (it.data.orderState) { |
| | | 2, 3, 4 -> { |
| | | if (it.data.orderState == 4) { |
| | | // showNumDialog { num -> |
| | | it.data.orderState++ |
| | | callStatue("1", it.data.orderState) { |
| | | iv_to_gd.callOnClick() |
| | | if (orderType == "4") { |
| | | businessMediaType = 0 |
| | | launcherForResult.launch( |
| | | MediaOperationActivity.getIntent( |
| | | this, |
| | | getString(R.string.请上传图片), |
| | | getString(R.string.确认取货), 3, 1 |
| | | ) |
| | | ) |
| | | } else { |
| | | it.data.orderState++ |
| | | callStatue("1", it.data.orderState, { |
| | | LogHelper.logRecord("更新订单状态为送件中成功orderId:${orderId} orderType:${orderType}") |
| | | iv_to_gd.callOnClick() |
| | | }) { code, msg -> |
| | | it.data.orderState-- |
| | | LogHelper.logRecord("更新订单状态为送件中失败orderId:${orderId} orderType:${orderType} code:${code} msg:${msg}") |
| | | } |
| | | showStatueMapUI(it) |
| | | } |
| | | showStatueMapUI(it) |
| | | // } |
| | | } else { |
| | | it.data.orderState++ |
| | | callStatue(it.data.orderState, "") { |
| | | callStatue(it.data.orderState, "", { |
| | | LogHelper.logRecord("更新订单状态成功orderId:${orderId} orderType:${orderType} state:${it.data.orderState}") |
| | | if (it.data.orderState == 3) |
| | | iv_to_gd.callOnClick() |
| | | }) { code, msg -> |
| | | it.data.orderState-- |
| | | LogHelper.logRecord("更新订单状态失败orderId:${orderId} orderType:${orderType} code:${code} msg:${msg}") |
| | | } |
| | | showStatueMapUI(it) |
| | | } |
| | | } |
| | | |
| | | 5, 6 -> { |
| | | sendCode() { |
| | | it.data.orderState = 6 |
| | | var dialog = |
| | | DialogUtil.getDialog(this, R.layout.dialog_show_cargo_money) |
| | | var viewContent = DialogUtil.getView(dialog) |
| | | val view_hint_close_car = |
| | | viewContent.find<View>(R.id.view_hint_close_car) |
| | | val tv_car_num_close = viewContent.find<View>(R.id.tv_car_num_close) |
| | | val tv_money = viewContent.find<TextView>(R.id.tv_money) |
| | | val tv_sure_car_num = viewContent.find<TextView>(R.id.tv_sure_car_num) |
| | | val et_num_zg = viewContent.find<EditText>(R.id.et_num_zg) |
| | | view_hint_close_car.setOnClickListener { |
| | | dialog.dismiss() |
| | | } |
| | | tv_car_num_close.setOnClickListener { |
| | | dialog.dismiss() |
| | | } |
| | | if (it.data.driverPay == "1") { |
| | | tv_money.visible() |
| | | tv_money.text = |
| | | getString(R.string.确认现金金额).format(if (it.data.payMoney == 0.0) it.data.orderMoney else it.data.payMoney) |
| | | .replace(",", ".") |
| | | } |
| | | tv_sure_car_num.setOnClickListener { |
| | | var num = et_num_zg.getContent() |
| | | if (num.isEmpty()) { |
| | | toast(getString(R.string.请输入验证码)) |
| | | return@setOnClickListener |
| | | } |
| | | callStatue(orderBean!!.data.orderState, num) { |
| | | dialog.dismiss() |
| | | // startActivity<SmallOverActivity>( |
| | | // "orderId" to orderId, |
| | | // "orderType" to orderType |
| | | // ) |
| | | /* startActivity<MajorSureMoneyActivity>( |
| | | "orderId" to orderId, |
| | | "orderType" to orderType |
| | | )*/ |
| | | finish() |
| | | } |
| | | } |
| | | } |
| | | // sendCode() { |
| | | businessMediaType = 1 |
| | | launcherForResult.launch( |
| | | MediaOperationActivity.getIntent( |
| | | this, |
| | | getString(R.string.请上传图片), |
| | | getString(R.string.确认送达), 3, 1 |
| | | ) |
| | | ) |
| | | // } |
| | | } |
| | | |
| | | 12 -> { |
| | | it.data.orderState = 5 |
| | | callStatue(it.data.orderState, "") {} |
| | | callStatue(it.data.orderState, "", { |
| | | LogHelper.logRecord("取消待支付订单更新状态为送件中成功orderId:${orderId} orderType:${orderType}") |
| | | }) { code, msg -> |
| | | LogHelper.logRecord("取消待支付订单更新状态为送件中失败orderId:${orderId} orderType:${orderType} code:${code} msg:${msg}") |
| | | } |
| | | showStatueMapUI(it) |
| | | } |
| | | |
| | |
| | | |
| | | } |
| | | |
| | | //显示确认送达弹窗 |
| | | private fun showConfirmDeliveryDialog(url: String) { |
| | | orderBean?.let { |
| | | it.data.orderState = 6 |
| | | val dialog = DialogUtil.getDialog(this, R.layout.dialog_show_cargo_money) |
| | | val viewContent = DialogUtil.getView(dialog) |
| | | val view_hint_close_car = viewContent.find<View>(R.id.view_hint_close_car) |
| | | val tv_car_num_close = viewContent.find<View>(R.id.tv_car_num_close) |
| | | val tv_money = viewContent.find<TextView>(R.id.tv_money) |
| | | val tv_sure_car_num = viewContent.find<TextView>(R.id.tv_sure_car_num) |
| | | val et_num_zg = viewContent.find<EditText>(R.id.et_num_zg) |
| | | view_hint_close_car.setOnClickListener { |
| | | dialog.dismiss() |
| | | } |
| | | tv_car_num_close.setOnClickListener { |
| | | dialog.dismiss() |
| | | } |
| | | if (it.data.driverPay == "1") { |
| | | tv_money.visible() |
| | | tv_money.text = |
| | | getString(R.string.确认现金金额).format( |
| | | if (orderType == "4") (it.data.payMoney.toDoubleOrNull() |
| | | ?: 0.0) else if (it.data.payMoney.isNullOrEmpty()) it.data.orderMoney else (it.data.payMoney.toDoubleOrNull() ?: 0.0) |
| | | ) |
| | | .replace(",", ".").extClearInvalidZero() |
| | | } |
| | | tv_sure_car_num.setOnClickListener { |
| | | val num = et_num_zg.getContent() |
| | | if (num.isEmpty()) { |
| | | toast(getString(R.string.请输入验证码)) |
| | | return@setOnClickListener |
| | | } |
| | | confirmDelivery(6, num, url, { |
| | | LogHelper.logRecord("确认快件已送达成功orderId:${orderId} orderType:${orderType}") |
| | | dialog.dismiss() |
| | | finish() |
| | | }) { code, msg -> |
| | | LogHelper.logRecord("确认快件已送达失败orderId:${orderId} orderType:${orderType} code:${code} msg:${msg}") |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | //显示确认价格弹窗 |
| | | private fun showConfirmPriceDialog(url: String) { |
| | | orderBean?.let { |
| | | DialogUtil.getDelAndSureDialog( |
| | | this, |
| | | getString(R.string.确认现金金额).format((it.data.payMoney.toDoubleOrNull() ?: 0.0)) |
| | | .replace(",", ".").extClearInvalidZero(), |
| | | {}, |
| | | { |
| | | confirmPickUp(url, 5, { |
| | | LogHelper.logRecord("确认收到此订单费用成功orderId:${orderId} orderType:${orderType}") |
| | | it.data.orderState = 5 |
| | | showStatueMapUI(it) |
| | | iv_to_gd.callOnClick() |
| | | }) { code, msg -> |
| | | LogHelper.logRecord("确认收到此订单费用失败orderId:${orderId} orderType:${orderType} code:${code} msg:${msg}") |
| | | } |
| | | }) |
| | | } |
| | | } |
| | | |
| | | fun startNavi(startLat: Double, startLon: Double, endLat: Double, endLon: Double) { |
| | | AMapKit.startNavi(this, startLat, startLon, endLat, endLon) |
| | | } |
| | | |
| | | private fun sendCode(function: () -> Unit) { |
| | | var map = getMapByAny() |
| | | map["orderId"] = orderId |
| | | callNet(Api.sendVerificationCode, map) { |
| | | function() |
| | | } |
| | | } |
| | | |
| | | private fun callNumberCargo(num: String, click: () -> Unit) { |
| | | var map = getMapByAny() |
| | | map["orderId"] = orderId |
| | | map["pickUpCode"] = num |
| | | callNet(Api.fillInPickUpCode, map) { |
| | | click() |
| | | } |
| | | } |
| | | |
| | | |
| | | private fun callseatmoney(num: String, click: () -> Unit) { |
| | | var map = getMapByAny() |
| | | private fun callseatmoney(num: String, click: () -> Unit, error: (code: Int, msg: String?) -> Unit) { |
| | | val map = getMapByAny() |
| | | map["orderId"] = orderId |
| | | map["difference"] = doubleTwo(num.toDouble()) |
| | | callNet(Api.makeUpTheDifference, map) { |
| | | callNet(Api.makeUpTheDifference, map, { |
| | | click() |
| | | } |
| | | }, error) |
| | | } |
| | | |
| | | private fun callStatue(i: Int, num: String, click: () -> Unit) { |
| | | var map = getMapByAny() |
| | | private fun callStatue(i: Int, num: String, click: () -> Unit, error: (code: Int, msg: String?) -> Unit) { |
| | | val map = getMapByAny() |
| | | map["orderId"] = orderId |
| | | map["orderType"] = orderType |
| | | map["state"] = i |
| | | if (!num.isNullOrEmpty()) |
| | | if (num.isNotEmpty()) |
| | | map["pickUpCode"] = num |
| | | Log.e("定位==============》", "${MyApplication.getLocation()?.latitude},${MyApplication.getLocation()?.longitude}") |
| | | Log.e( |
| | | "定位==============》", |
| | | "${MyApplication.getLocation()?.latitude},${MyApplication.getLocation()?.longitude}" |
| | | ) |
| | | map["lat"] = MyApplication.getLocation()?.latitude ?: 0.0 |
| | | map["lon"] = MyApplication.getLocation()?.longitude ?: 0.0 |
| | | callNet(Api.process, map) { |
| | | OrderTimeOutManager.instance.checkOrderManager(orderId, orderType, i) |
| | | callNet(Api.process, map, { |
| | | click() |
| | | } |
| | | }, error) |
| | | } |
| | | |
| | | private fun callStatue(phone: String, i: Int, click: () -> Unit) { |
| | | var map = getMapByAny() |
| | | //确认送达 |
| | | private fun confirmDelivery(i: Int, num: String, imgTwo: String, click: () -> Unit, error: (code: Int, msg: String?) -> Unit) { |
| | | val map = getMapByAny() |
| | | map["orderId"] = orderId |
| | | map["orderType"] = orderType |
| | | map["state"] = i |
| | | if (num.isNotEmpty()) |
| | | map["pickUpCode"] = num |
| | | Log.e( |
| | | "定位==============》", |
| | | "${MyApplication.getLocation()?.latitude},${MyApplication.getLocation()?.longitude}" |
| | | ) |
| | | map["imgTwo"] = imgTwo |
| | | map["lat"] = MyApplication.getLocation()?.latitude ?: 0.0 |
| | | map["lon"] = MyApplication.getLocation()?.longitude ?: 0.0 |
| | | callNet(Api.process, map, { |
| | | click() |
| | | }, error) |
| | | } |
| | | |
| | | private fun callStatue(phone: String, i: Int, click: () -> Unit, error: (code: Int, msg: String?) -> Unit) { |
| | | val map = getMapByAny() |
| | | map["orderId"] = orderId |
| | | map["orderType"] = orderType |
| | | map["state"] = i |
| | | // map["phone"] = phone |
| | | map["lat"] = MyApplication.getLocation()?.latitude ?: 0.0 |
| | | map["lon"] = MyApplication.getLocation()?.longitude ?: 0.0 |
| | | callNet(Api.process, map) { |
| | | OrderTimeOutManager.instance.checkOrderManager(orderId, orderType, i) |
| | | callNet(Api.process, map, { |
| | | click() |
| | | } |
| | | }, error) |
| | | } |
| | | |
| | | //确认收获 |
| | | private fun confirmPickUp(imgOne: String, i: Int, click: () -> Unit, error: (code: Int, msg: String?) -> Unit) { |
| | | val map = getMapByAny() |
| | | map["orderId"] = orderId |
| | | map["orderType"] = orderType |
| | | map["imgOne"] = imgOne |
| | | map["state"] = i |
| | | map["lat"] = MyApplication.getLocation()?.latitude ?: 0.0 |
| | | map["lon"] = MyApplication.getLocation()?.longitude ?: 0.0 |
| | | callNet(Api.process, map, { |
| | | click() |
| | | }, error) |
| | | } |
| | | |
| | | private var movedByFinger = false |
| | |
| | | */ |
| | | var lastMoveByGesture = 0L //上次手势操作的时间 |
| | | private fun initMineLocation() { |
| | | aMap.setOnMyLocationChangeListener { |
| | | it.let { latlon -> |
| | | MyApplication.aMapLocation = LatLng(it.latitude,it.longitude) |
| | | aMap.setOnMyLocationChangeListener { it -> |
| | | it?.let { |
| | | MyApplication.setLocation(it.latitude, it.longitude) |
| | | } |
| | | orderBean?.let { |
| | | when (it.data.orderState) { |
| | | 2, 3 -> { |
| | | changeCarThree(false) |
| | | } |
| | | 4->{ |
| | | |
| | | 4 -> { |
| | | //getTripInfo(4,false) |
| | | changeCarThree(false) |
| | | } |
| | | |
| | | 5, 6 -> { |
| | | changeCarFive(false) |
| | | } |
| | | } |
| | | } |
| | | |
| | | // it.let { latlon -> |
| | | // carMarker?.position = LatLng(latlon.latitude, latlon.longitude) |
| | | // graylist.add(LatLng(latlon.latitude, latlon.longitude)) |
| | | // grayline?.remove() |
| | | // grayline = AMapKit.drawLine(this, aMap, graylist, R.color.gray) |
| | | // MyApplication.aMapLocation = LatLng(it.latitude, it.longitude) |
| | | // orderBean?.let { |
| | | // when (it.data.orderState) { |
| | | // 2, 3 -> { |
| | | // changeCarThree(false) |
| | | // } |
| | | // |
| | | // 5, 6 -> { |
| | | // changeCarFive(false) |
| | | // } |
| | | // } |
| | | // } |
| | | // } |
| | | } |
| | | } |
| | | |
| | |
| | | carMarker!!.position, |
| | | object : (MutableList<LatLng>, Float, Long) -> Unit { |
| | | override fun invoke(p1: MutableList<LatLng>, p2: Float, p3: Long) { |
| | | |
| | | if (isFinishing || isDestroyed) { |
| | | return |
| | | } |
| | | val tance = AMapKit.getTance(this@SmallCargoActivity, p2) |
| | | val content = getString(R.string.距取货点, tance) |
| | | val sp = SpanBuilder.content(content) |
| | |
| | | content.indexOf(tance) + tance.length, |
| | | R.color.color_5DB03D |
| | | ).build() |
| | | var view = creatCarView(sp) |
| | | val view = creatCarView(sp) |
| | | carMarker!!.setIcon(getIcon(view)) |
| | | addline(p1) |
| | | if (isMove) |
| | |
| | | endMarker!!.position, |
| | | object : (MutableList<LatLng>, Float, Long) -> Unit { |
| | | override fun invoke(p1: MutableList<LatLng>, p2: Float, p3: Long) { |
| | | if (isFinishing || isDestroyed) { |
| | | return |
| | | } |
| | | addline(p1) |
| | | |
| | | val tance = AMapKit.getTance(this@SmallCargoActivity, p2) |
| | |
| | | content.indexOf(time) + time.length, |
| | | R.color.color_5DB03D |
| | | ).build() |
| | | var view = |
| | | creatCarView(sp) |
| | | val view = creatCarView(sp) |
| | | carMarker!!.setIcon(getIcon(view)) |
| | | if (isMove) { |
| | | moveCamera(aMap, carMarker!!.position, endMarker!!.position) |
| | |
| | | } |
| | | } |
| | | |
| | | private fun callOrder(reNavi:Boolean = false,function: () -> Unit) { |
| | | private fun callOrder(reNavi: Boolean = false, function: () -> Unit) { |
| | | MyApplication.currentOrderId = orderId |
| | | MyApplication.currentOrderType = orderType |
| | | var map = getMapByAny() |
| | | val map = getMapByAny() |
| | | map["orderId"] = orderId |
| | | map["orderType"] = orderType |
| | | callNet(Api.queryOrderInfo, map) { |
| | | orderBean = gson.fromJson(it, OrderBean::class.java) |
| | | showUi(orderBean) |
| | | function() |
| | | if (reNavi){ |
| | | EventBus.getDefault().post(BaseEvent(BaseEvent.RELOAD_NAVI,orderBean!!.data.endLat.toString(),orderBean!!.data.endLon.toString())) |
| | | callNet(Api.queryOrderInfo, map) { it -> |
| | | gson.fromJson(it, OrderBean::class.java)?.also { |
| | | orderBean = it |
| | | showUi(it) |
| | | function() |
| | | if (reNavi) { |
| | | EventBus.getDefault().post( |
| | | BaseEvent( |
| | | BaseEvent.RELOAD_NAVI, |
| | | it.data?.endLat?.toString(), |
| | | it.data?.endLon?.toString() |
| | | ) |
| | | ) |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | private fun showUi(orderBean: OrderBean?) { |
| | | orderBean?.let { |
| | | if (it.data.isFrozen == 2){ |
| | | if (it.data.isFrozen == 2) { |
| | | toast(getString(R.string.已冻结)) |
| | | finish() |
| | | } |
| | |
| | | // tv_money_cargo.gone() |
| | | // } |
| | | if (!it.data.differenceMoney.isNullOrEmpty() && it.data.differenceMoney.toDouble() > 0) { |
| | | btn_gap_money.text = getString(R.string.差价点击修改).format(it.data.differenceMoney.toDouble()) |
| | | btn_gap_money.setCompoundDrawablesRelativeWithIntrinsicBounds(0,0,0,0) |
| | | btn_gap_money.text = |
| | | getString(R.string.差价点击修改).format(it.data.differenceMoney.extClearInvalidZero()) |
| | | btn_gap_money.setCompoundDrawablesRelativeWithIntrinsicBounds(0, 0, 0, 0) |
| | | } |
| | | var latLngList = mutableListOf<LatLng>() |
| | | val latLngList = mutableListOf<LatLng>() |
| | | for (item in orderBean.data.orderPositionList) { |
| | | latLngList.add(LatLng(item.lat, item.lon)) |
| | | } |
| | |
| | | val view = createView(R.layout.item_map_market, this) |
| | | view.find<ImageView>(R.id.iv_img).setImageResource(UiUtil.getLangEndBitmap()) |
| | | endMarker = addMarker(aMap, it.data.endLat, it.data.endLon, view, "") |
| | | }else{ //可能修改终点 |
| | | } else { //可能修改终点 |
| | | endMarker?.position = LatLng(it.data.endLat, it.data.endLon) |
| | | } |
| | | endMarker!!.isVisible = false |
| | |
| | | } |
| | | } |
| | | |
| | | private fun getTripInfo(state:Int,isMove: Boolean){ |
| | | /* var map = getMapByAny() |
| | | map["orderId"] = orderId |
| | | map["orderType"] = orderType |
| | | Log.e("QXS=mmp","getTripInfo:state=${state},orderId=${orderId},orderType=${orderType}") |
| | | callNet(false,Api.getTripInfo, map) { |
| | | val bean = Gson().fromJson(it, StringBean::class.java) |
| | | if (bean.code == 200&&!bean.data.isNullOrEmpty()){ |
| | | val trip = Gson().fromJson(bean.data, GoogleTripInfo::class.java) |
| | | val latlon = if (trip?.lastLocation == null) LocationX(MyApplication.aMapLocation!!.latitude,MyApplication.aMapLocation!!.longitude) else trip.lastLocation.location //车辆位置 |
| | | carMarker?.position = LatLng(latlon.latitude, latlon.longitude) |
| | | if (state != 4){ |
| | | graylist.add(LatLng(latlon.latitude, latlon.longitude)) |
| | | grayline?.remove() |
| | | grayline = AMapKit.drawLine(this, aMap, graylist, R.color.gray) |
| | | val routs = arrayListOf<LatLng>() |
| | | if (!trip.route.isNullOrEmpty()) |
| | | routs.addAll(trip.route.map { LatLng(it.latitude,it.longitude) }) |
| | | addline(routs) |
| | | }else{ |
| | | closeLine() |
| | | graylist.clear() |
| | | grayline?.remove() |
| | | } |
| | | if (state == 3){ |
| | | val tance = AMapKit.getTance(this@SmallCargoActivity, trip.remainingDistanceMeters.toFloat()) |
| | | val content = getString(R.string.距取货点, tance) |
| | | val sp = SpanBuilder.content(content) |
| | | .colorSpan( |
| | | this@SmallCargoActivity, |
| | | content.indexOf(tance), |
| | | content.indexOf(tance) + tance.length, |
| | | R.color.color_5DB03D |
| | | ).build() |
| | | var view = creatCarView(sp) |
| | | carMarker!!.setIcon(getIcon(view)) |
| | | } |
| | | if (state == 5){ |
| | | val tance = AMapKit.getTance(this, trip.remainingDistanceMeters.toFloat()) |
| | | val seconds = trip.remainingWaypoints?.firstOrNull()?.duration ?:"0s" |
| | | val time = (seconds.substring(0,seconds.length-1).toDouble()/60).toInt().toString() |
| | | val content = getString(R.string.预计还需, tance, time) |
| | | val sb = SpanBuilder.content(content).colorSpan(this,content.indexOf(tance),content.indexOf(tance)+tance.length,R.color.color_5DB03D) |
| | | .colorSpan(this,content.indexOf(time),content.indexOf(time)+time.length,R.color.color_5DB03D).build() |
| | | var view = creatCarView(sb) |
| | | carMarker!!.setIcon(getIcon(view)) |
| | | } |
| | | if (isMove) { |
| | | iv_move.callOnClick() |
| | | } |
| | | } |
| | | }*/ |
| | | } |
| | | |
| | | |
| | | private fun startTimeStart(waitTime: Int) { |
| | | if (!isTimeStart) { |
| | | isTimeStart = true |
| | |
| | | content.indexOf(timeType) + timeType.length, |
| | | R.color.main_login_orange |
| | | ).build() |
| | | var view = creatCarViewHint(build) |
| | | val view = creatCarViewHint(build) |
| | | carMarker!!.setIcon(getIcon(view)) |
| | | } |
| | | } |
| | |
| | | .observeOn(AndroidSchedulers.mainThread()) |
| | | .compose(bindUntilEvent(ActivityEvent.DESTROY)) |
| | | .subscribe { aLong -> |
| | | var num = waitTime + aLong |
| | | val num = waitTime + aLong |
| | | click(num.toInt()) |
| | | } |
| | | } |
| | |
| | | |
| | | override fun onDestroy() { |
| | | super.onDestroy() |
| | | MyApplication.removeOrderView(listener) |
| | | if (handler != null) { |
| | | handler?.removeCallbacksAndMessages(null) |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | 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() { |
| | | |
| | | } |
| | | |
| | | |
| | | @SuppressLint("MissingPermission") |
| | | override fun onCreate(savedInstanceState: Bundle?) { |
| | | super.onCreate(savedInstanceState) |
| | | var fragment = supportFragmentManager.findFragmentById(R.id.map_view) as SupportMapFragment |
| | | val fragment = supportFragmentManager.findFragmentById(R.id.map_view) as SupportMapFragment |
| | | initMap(fragment) { |
| | | mapInitStatus = true |
| | | aMap = it |
| | |
| | | MyApplication.currentOrderType = "" |
| | | finish() |
| | | } |
| | | |
| | | BaseEvent.BACK_CAR_OVER -> { |
| | | finish() |
| | | } |
| | | |
| | | BaseEvent.DIFF_PRICE_AGREE -> { |
| | | if (mapInitStatus) initView2() |
| | | } |
| | | |
| | | BaseEvent.DIFF_PRICE_REFUSE -> { |
| | | btn_gap_money.text = getString(R.string.补差价) |
| | | btn_gap_money.setCompoundDrawablesRelativeWithIntrinsicBounds(R.mipmap.ic_add,0,0,0) |
| | | btn_gap_money.setCompoundDrawablesRelativeWithIntrinsicBounds( |
| | | R.mipmap.ic_add, |
| | | 0, |
| | | 0, |
| | | 0 |
| | | ) |
| | | } |
| | | |
| | | BaseEvent.MODIFY_ADDRESS_SUC -> { |
| | | callOrder(true){} |
| | | callOrder(true) {} |
| | | } |
| | | } |
| | | } |