package com.future.driver.ui.to_city
|
|
import android.os.Bundle
|
import android.os.CountDownTimer
|
import android.view.View
|
import cn.sinata.xldutils.activitys.DialogActivity
|
import cn.sinata.xldutils.utils.*
|
import com.amap.api.maps.AMap
|
import com.amap.api.maps.model.LatLng
|
import com.future.driver.R
|
import com.future.driver.base.MyApplication
|
import com.future.driver.base.gaode.AMapKit
|
import com.future.driver.bean.OrderBean
|
import com.future.driver.netUtls.*
|
import com.future.driver.ui.UiUtil
|
import com.google.gson.Gson
|
import kotlinx.android.synthetic.main.item_get_order.*
|
import kotlinx.android.synthetic.main.item_map_market.view.*
|
import org.jetbrains.anko.startActivity
|
|
class GetCityFragment : DialogActivity() {
|
|
val orderId by lazy {
|
intent?.getStringExtra("orderId")
|
}
|
val orderType by lazy {
|
intent?.getStringExtra("orderType")
|
}
|
|
lateinit var time: CountDownTimer
|
|
|
override fun onCreate(savedInstanceState: Bundle?) {
|
super.onCreate(savedInstanceState)
|
//实例化语音引擎
|
aMap = AMapKit.initMap(savedInstanceState, map_view)
|
var strBtn = "确定"
|
tv_sure.text = strBtn
|
tv_close.clickDelay {
|
finish()
|
}
|
callOrderDetail()
|
tv_sure.clickDelay {
|
this.startActivity<TripCityActivity>("orderId" to orderId, "orderType" to orderType)
|
finish()
|
}
|
}
|
|
override fun initView() {
|
|
}
|
|
|
override fun setContentLayout(): Int {
|
return R.layout.item_get_order
|
}
|
|
|
private fun callOrderDetail() {
|
|
var map = getMapByAny()
|
map["orderId"] = orderId
|
map["orderType"] = orderType
|
map["lat"] = MyApplication.getLocation().latitude
|
map["lon"] = MyApplication.getLocation().longitude
|
callNet(this, Api.queryPushOrder, map) {
|
val data = Gson().fromJson<OrderBean>(it, OrderBean::class.java).data
|
sysErr(data)
|
val startView = createView(R.layout.item_map_market, this)
|
val endView = createView(R.layout.item_map_market, this)
|
startView.iv_img.setImageResource(R.mipmap.starting_yellow_point)
|
endView.iv_img.setImageResource(R.mipmap.end_point)
|
AMapKit.addMarker(aMap, data.startLat, data.startLon, startView, "")
|
AMapKit.addMarker(aMap, data.endLat, data.endLon, endView, "")
|
tv_time.text = data.travelTime
|
tv_car_type.text = UiUtil.getNameByType(orderType!!) + "订单"
|
if (orderType!! == "3"){
|
tv_money.setDrawableLeft(R.mipmap.icon_people_gray)
|
}
|
tv_remark.visibility = if (data.remark.isNullOrEmpty()) View.GONE else View.VISIBLE
|
if (!data.remark.isNullOrEmpty()) {
|
tv_remark.text = data.remark
|
}
|
if (orderType == "1") {
|
tv_money.gone()
|
}
|
tv_start.text = data.startAddress
|
tv_end.text = data.endAddress
|
tv_money.text = data.people.toString() + "人"
|
tv_reassign.text = data.type
|
AMapKit.drawLineAndMove(
|
this,
|
aMap,
|
LatLng(data.startLat, data.startLon),
|
LatLng(data.endLat, data.endLon), 100
|
)
|
AMapKit.initRouteLine(
|
this,
|
LatLng(data.startLat, data.startLon),
|
LatLng(data.endLat, data.endLon),
|
object : (MutableList<LatLng>, Float, Long) -> Unit {
|
override fun invoke(
|
latLngs: MutableList<LatLng>,
|
lineTance: Float,
|
lineTime: Long
|
) {
|
tv_tance.text = "全程约" + AMapKit.getTance(lineTance)
|
MyApplication.getTTsManager().setVideoText(
|
"收到新的" + UiUtil.getNameByType(orderType!!) + "订单," + "从" + data.startAddress + "出发,全程约" + AMapKit.getTance(
|
lineTance
|
)
|
)
|
}
|
|
})
|
AMapKit.initRouteLine(
|
this,
|
LatLng(MyApplication.getLocation().latitude, MyApplication.getLocation().longitude),
|
LatLng(data.startLat, data.startLon),
|
object : (MutableList<LatLng>, Float, Long) -> Unit {
|
override fun invoke(
|
latLngs: MutableList<LatLng>,
|
lineTance: Float,
|
lineTime: Long
|
) {
|
tv_title.text = "距您约" + AMapKit.getTance(lineTance)
|
}
|
})
|
}
|
}
|
|
lateinit var aMap: AMap
|
|
}
|