| | |
| | | import android.widget.ImageView |
| | | import android.widget.TextView |
| | | 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.ui.DialogUtil |
| | | import com.driver.igotrip.ui.UiUtil |
| | | 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 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) |
| | | } |
| | | |
| | | override fun initView() { |
| | |
| | | MyApplication.addOrderView(object : MyApplication.OrderStatueView { |
| | | override fun orderInfo(data: OrderSimpleData?) { |
| | | data?.let { |
| | | if (it.status == 10 || it.status == 11|| it.status == 12) { |
| | | 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)) { |
| | | 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() {} |
| | | } |
| | |
| | | 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 { |
| | |
| | | callseatmoney(num) { |
| | | dialog.dismiss() |
| | | btn_gap_money.text = getString(R.string.差价待确认).format(num.toDouble()) |
| | | btn_gap_money.setCompoundDrawablesRelativeWithIntrinsicBounds(0,0,0,0) |
| | | btn_gap_money.setCompoundDrawablesRelativeWithIntrinsicBounds(0, 0, 0, 0) |
| | | // toast(getString(R.string.set_success)) |
| | | } |
| | | } |
| | |
| | | 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") { |
| | | DialogUtil.getDelAndSureDialog( |
| | | this, |
| | | getString(R.string.确认现金金额).format(it.data.expressPayAllMoney) |
| | | .replace(",", "."), |
| | | {}, |
| | | { |
| | | it.data.orderState++ |
| | | callStatue("1", it.data.orderState) { |
| | | iv_to_gd.callOnClick() |
| | | } |
| | | showStatueMapUI(it) |
| | | }) |
| | | } else { |
| | | it.data.orderState++ |
| | | callStatue("1", it.data.orderState) { |
| | | iv_to_gd.callOnClick() |
| | | } |
| | | showStatueMapUI(it) |
| | | } |
| | | showStatueMapUI(it) |
| | | // } |
| | | } else { |
| | | it.data.orderState++ |
| | | callStatue(it.data.orderState, "") { |
| | |
| | | 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) |
| | | getString(R.string.确认现金金额).format(if (orderType == "4") it.data.expressPayAllMoney else if (it.data.payMoney == 0.0) it.data.orderMoney else it.data.payMoney) |
| | | .replace(",", ".") |
| | | } |
| | | tv_sure_car_num.setOnClickListener { |
| | |
| | | // "orderId" to orderId, |
| | | // "orderType" to orderType |
| | | // ) |
| | | /* startActivity<MajorSureMoneyActivity>( |
| | | "orderId" to orderId, |
| | | "orderType" to orderType |
| | | )*/ |
| | | /* startActivity<MajorSureMoneyActivity>( |
| | | "orderId" to orderId, |
| | | "orderType" to orderType |
| | | )*/ |
| | | finish() |
| | | } |
| | | } |
| | |
| | | map["state"] = i |
| | | if (!num.isNullOrEmpty()) |
| | | 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) { |
| | |
| | | private fun initMineLocation() { |
| | | aMap.setOnMyLocationChangeListener { |
| | | it.let { latlon -> |
| | | MyApplication.aMapLocation = LatLng(it.latitude,it.longitude) |
| | | MyApplication.aMapLocation = LatLng(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) |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | 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() |
| | |
| | | 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())) |
| | | if (reNavi) { |
| | | EventBus.getDefault().post( |
| | | BaseEvent( |
| | | BaseEvent.RELOAD_NAVI, |
| | | orderBean!!.data.endLat.toString(), |
| | | orderBean!!.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.toDouble()) |
| | | btn_gap_money.setCompoundDrawablesRelativeWithIntrinsicBounds(0, 0, 0, 0) |
| | | } |
| | | var latLngList = mutableListOf<LatLng>() |
| | | for (item in orderBean.data.orderPositionList) { |
| | |
| | | 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 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() |
| | | } |
| | | } |
| | | }*/ |
| | | } |
| | | |
| | | |
| | |
| | | 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) {} |
| | | } |
| | | } |
| | | } |