package com.kuanzhai.user.ui.official
|
|
import android.Manifest
|
import android.animation.ObjectAnimator
|
import android.app.Activity
|
import android.content.Intent
|
import android.graphics.Color
|
import android.os.Bundle
|
import android.util.Log
|
import android.util.TypedValue
|
import android.view.View
|
import android.widget.TextView
|
import androidx.core.os.bundleOf
|
import cn.sinata.amaplib.overlay.DrivingRouteOverlay
|
import cn.sinata.xldutils.fragment.BaseFragment
|
import cn.sinata.xldutils.gone
|
import cn.sinata.xldutils.ioScheduler
|
import cn.sinata.xldutils.rxutils.ResultException
|
import cn.sinata.xldutils.utils.SpanBuilder
|
import cn.sinata.xldutils.utils.myToast
|
import cn.sinata.xldutils.utils.optInt
|
import cn.sinata.xldutils.utils.showAllowingStateLoss
|
import cn.sinata.xldutils.visible
|
import com.amap.api.maps.AMap
|
import com.amap.api.maps.CameraUpdateFactory
|
import com.amap.api.maps.TextureMapView
|
import com.amap.api.maps.model.*
|
import com.amap.api.services.core.LatLonPoint
|
import com.amap.api.services.poisearch.PoiResult
|
import com.amap.api.services.poisearch.PoiSearch
|
import com.amap.api.services.route.*
|
import com.autonavi.amap.mapcore.Inner_3dMap_location
|
import com.flyco.tablayout.listener.CustomTabEntity
|
import com.flyco.tablayout.listener.OnTabSelectListener
|
import com.google.gson.Gson
|
import com.kuanzhai.user.KuanzhaiApplication
|
import com.kuanzhai.user.R
|
import com.kuanzhai.user.dialog.*
|
import com.kuanzhai.user.interfaces.StringCallback
|
import com.kuanzhai.user.network.HttpManager
|
import com.kuanzhai.user.network.entity.CarPrice
|
import com.kuanzhai.user.network.entity.Passenger
|
import com.kuanzhai.user.network.requestByF
|
import com.kuanzhai.user.ui.MainActivity
|
import com.kuanzhai.user.ui.charter.CharterActivity
|
import com.kuanzhai.user.ui.mine.VerifyCompanyActivity
|
import com.kuanzhai.user.ui.trip.ChoosePositionActivity
|
import com.kuanzhai.user.ui.trip.TripActivity
|
import com.kuanzhai.user.utils.Const
|
import com.kuanzhai.user.views.textbanner.TextBannerView
|
import com.tbruyelle.rxpermissions2.RxPermissions
|
import io.reactivex.Flowable
|
import io.reactivex.subscribers.DisposableSubscriber
|
import kotlinx.android.synthetic.main.fragment_official.*
|
import kotlinx.android.synthetic.main.item_car_price.view.*
|
import org.greenrobot.eventbus.EventBus
|
import org.jetbrains.anko.backgroundResource
|
import org.jetbrains.anko.sdk27.coroutines.onClick
|
import org.jetbrains.anko.support.v4.*
|
|
/**
|
* 公务用车
|
*/
|
class OfficialFragment : BaseFragment(), RouteSearch.OnRouteSearchListener {
|
override fun contentViewId() = R.layout.fragment_official
|
|
var type = Const.OrderType.TYPE_OFFICIAL //默认公务用车
|
var savedInstanceState: Bundle? = null
|
private val mainActivity by lazy {
|
activity as MainActivity
|
}
|
private val mMapView by lazy {
|
find<TextureMapView>(R.id.mMapView)
|
}
|
private val aMap by lazy {
|
mMapView.map
|
}
|
private val titles = arrayOf("预约","代叫")
|
private var startByChoose = false //true 通过选择出发地移动地图,false 通过手势拖动地图
|
private var startByLocal = false //true 通过复位按钮移动地图,false 通过手势拖动地图
|
|
//出发经纬度
|
private var startLon = 0.0
|
private var startLat = 0.0
|
private var startName = ""
|
//到达经纬度
|
private var endLon = 0.0
|
private var endLat = 0.0
|
private var endName = ""
|
|
private var timeParam = "" //预约时间请求参数
|
private var endTimeParam = "" //包车结束时间请求参数
|
private var drivingRouteOverlay: DrivingRouteOverlay? = null
|
|
private var calType = 0 //计费方式(1单程计费,2=包车计费)
|
|
private var carTypeId = 0 //车型id
|
private var carTypeIndex = 0 //选中的位置
|
|
private val passenger = arrayListOf<Passenger>()
|
private var payType = 0 //付费方式(1=自费,2=企业支付)
|
private var reason = ""
|
|
private var isNotice = 0 //包车:是否提醒用户(0不提醒,1提醒)
|
|
override fun onFirstVisibleToUser() {
|
mMapView.onCreate(savedInstanceState)
|
getNotice()
|
initTab()
|
initClick()
|
|
getRxPermission {
|
initMap()
|
}
|
}
|
|
private fun initClick(){
|
tv_time.setOnClickListener {
|
val chooseReserveTimeDialog = ChooseReserveTimeDialog()
|
chooseReserveTimeDialog.setCallback(object : ChooseReserveTimeDialog.Callback {
|
override fun onOk(s: String, formatS: String) {
|
tv_time.text = s
|
timeParam = formatS
|
}
|
})
|
chooseReserveTimeDialog.show(fragmentManager!!, "time")
|
}
|
tv_reason.setOnClickListener {
|
showDialog()
|
HttpManager.getBusinessReason().requestByF(this){_,data->
|
val reason = arrayListOf<String>()
|
reason.addAll(data?.map { it.name }?: arrayListOf())
|
ReasonDialog.show(childFragmentManager,payType,reason,passenger,tv_reason.text.toString(),this@OfficialFragment.reason,object :ReasonDialog.ReasonCallback{
|
override fun onResult(
|
passengers: List<Passenger>,
|
reason: String,
|
payWay: Int,
|
remark: String
|
) {
|
tv_reason.text = reason
|
passenger.clear()
|
passenger.addAll(passengers)
|
payType = payWay
|
this@OfficialFragment.reason = remark
|
}
|
})
|
}
|
|
}
|
tv_way.setOnClickListener {
|
if (checkPermission()){
|
val singleWheelDialog = SingleWheelDialog()
|
singleWheelDialog.arguments = bundleOf("data" to arrayListOf("单程计费","包车计费"),"title" to "选择用车计费")
|
singleWheelDialog.setCallback(object :StringCallback{
|
override fun onRlt(rlt: String) {
|
if (rlt == "包车计费"){
|
if (passenger.isEmpty())
|
passenger.add(Passenger((requireActivity() as MainActivity).userInfo?.name?:"",(requireActivity() as MainActivity).userInfo?.phone?:""))
|
startActivityForResult<CharterActivity>(3,"startTime" to timeParam,"passenger" to passenger,"start" to startName,"startLat" to startLat,"startLon" to startLon,
|
"end" to endName,"endLat" to endLat,"endLon" to endLon,"endTime" to endTimeParam,"isRemind" to (isNotice == 1))
|
}else{
|
if (calType!=1&&sc_type.visibility == View.VISIBLE){ //之前请求过车型并且计费方式发生变化,需重新请求车型
|
calType = 1
|
getCarType()
|
}
|
tv_way.text = rlt
|
calType = 1
|
}
|
}
|
})
|
singleWheelDialog.showAllowingStateLoss(childFragmentManager,"way")
|
}
|
}
|
tv_start.setOnClickListener {
|
if (checkPermission())
|
startActivityForResult<ChoosePositionActivity>(1,"isOfficial" to true)
|
}
|
tv_end.setOnClickListener {
|
if (checkPermission())
|
startActivityForResult<ChoosePositionActivity>(2,"isOfficial" to true,"isStart" to false)
|
}
|
tv_action.setOnClickListener {
|
if (tv_action.text == "预约出行"){
|
if (timeParam.isEmpty()){
|
myToast("请选择用车时间")
|
return@setOnClickListener
|
}
|
if (tv_reason.text == "事由出行"){
|
myToast("请选择出行事由")
|
return@setOnClickListener
|
}
|
if (calType == 2&&endTimeParam.isEmpty()){
|
myToast("请选择用车结束时间")
|
return@setOnClickListener
|
}
|
tv_action.isEnabled = false
|
HttpManager.saveOrderBusiness(calType,endName,endLat,endLon,isNotice,1,if (tab_type.currentTab == 0) 2 else 1,payType,
|
Gson().toJson(passenger),reason,tv_reason.text.toString(),passenger.size,KuanzhaiApplication.lat,KuanzhaiApplication.lon,carTypeId,startLat,
|
startLon,startName,tab_type.currentTab,if (calType == 1) null else endTimeParam,timeParam,1,null).requestByF(this,success = {_,data->
|
startActivity<TripActivity>("type" to type, "id" to data?.optInt("id"))
|
back()
|
}
|
){_,_->
|
tv_action.isEnabled = true
|
}
|
}else{
|
if (startLat == 0.0){
|
myToast("请选择出发地")
|
return@setOnClickListener
|
}
|
if (endLat == 0.0){
|
myToast("请选择目的地")
|
return@setOnClickListener
|
}
|
if (calType == 2){
|
if (timeParam.isEmpty()){
|
myToast("请选择用车时间")
|
return@setOnClickListener
|
}
|
if (endTimeParam.isEmpty()){
|
myToast("请选择用车结束时间")
|
return@setOnClickListener
|
}
|
}
|
if (calType == 0){
|
myToast("请选择计费方式")
|
return@setOnClickListener
|
}
|
tv_action.isEnabled = false
|
getCarType()
|
}
|
}
|
iv_back.setOnClickListener {
|
back()
|
}
|
}
|
|
/**
|
* 查询车型和价格
|
*/
|
private var nowCarType: CarPrice? = null
|
private fun getCarType() {
|
showDialog()
|
HttpManager.queryBusinessCarModel("$startLon,$startLat", "$endLon,$endLat", calType,if (calType == 1) null else "$timeParam:00",if (calType == 1) null else "$endTimeParam:00")
|
.requestByF(this, success = { _, data ->
|
sc_type.visible()
|
cl_1.gone()
|
tv_action.text = "预约出行"
|
tv_action.isEnabled = true
|
mainActivity.updateTitleVisibility(false, true)
|
|
data?.let { list ->
|
ll_type.removeAllViews()
|
if (list.isEmpty()) {
|
val content = "当前暂无可用车\n请拨打平台电话(023-88888888)预约用车"
|
tv_empty.text = SpanBuilder(content).color(requireContext(),content.indexOf("("),content.indexOf(")"),R.color.color_text_price).build()
|
tv_empty.visible()
|
} else {
|
tv_error.gone()
|
tv_retry.gone()
|
list.forEachIndexed { index, it ->
|
val view =
|
layoutInflater.inflate(R.layout.item_car_price, ll_type, false)
|
view.tv_name.text = it.name
|
view.tv_price.text = String.format("预估%.2f", it.amount)
|
view.iv_car.setImageURI(it.img)
|
if (index == 0){ //母贝:2022.6.7 默认选中第一项
|
carTypeId = it.id
|
view.tv_name.isChecked = true
|
view.tv_price.isChecked = true
|
view.ll_car.elevation = dip(3).toFloat()
|
view.ll_car.backgroundResource = R.drawable.bg_white_6dp
|
nowCarType = it
|
}
|
view.onClick { _ ->
|
if (index != carTypeIndex) {
|
view.tv_name.isChecked = true
|
view.tv_price.isChecked = true
|
view.ll_car.elevation = dip(5).toFloat()
|
view.ll_car.backgroundResource = R.drawable.bg_white_6dp
|
if (carTypeIndex != -1)
|
ll_type.getChildAt(carTypeIndex).apply {
|
tv_name.isChecked = false
|
tv_price.isChecked = false
|
ll_car.elevation = 0f
|
ll_car.backgroundResource = 0
|
}
|
carTypeIndex = index
|
carTypeId = it.id
|
nowCarType = it
|
}
|
}
|
ll_type.addView(view)
|
}
|
}
|
}
|
}) { _, _ ->
|
tv_error.visible()
|
tv_retry.visible()
|
sc_type.visible()
|
cl_1.gone()
|
tv_action.text = "预约出行"
|
tv_action.isEnabled = true
|
mainActivity.updateTitleVisibility(false, true)
|
}
|
}
|
|
|
|
private fun getNotice() {
|
HttpManager.queryNotices(1).requestByF(this) { _, data ->
|
data?.let {
|
val list = arrayListOf<String>()
|
list.addAll(it.map {
|
it.content
|
})
|
(textBanner as TextBannerView<String>).setDatas(list)
|
}
|
}
|
}
|
|
fun getRxPermission(function: () -> Unit) {
|
val disposable =
|
RxPermissions(activity!!).request(Manifest.permission.ACCESS_FINE_LOCATION)
|
.subscribe {
|
if (it) {
|
function()
|
} else {
|
function()
|
// myToast("没有定位权限")
|
}
|
}
|
onBindHelper(disposable)
|
}
|
|
private fun initTab() {
|
val list = arrayListOf<CustomTabEntity>()
|
val tabs = titles.map {
|
object : CustomTabEntity {
|
override fun getTabUnselectedIcon() = 0
|
|
override fun getTabSelectedIcon() = 0
|
|
override fun getTabTitle() = it
|
}
|
}
|
list.addAll(tabs)
|
tab_type.setTabData(list)
|
tab_type.currentTab = 0
|
tab_type.getTitleView(0).setTextSize(TypedValue.COMPLEX_UNIT_SP,16f)
|
tab_type.setOnTabSelectListener(object : OnTabSelectListener {
|
override fun onTabSelect(position: Int) {
|
if (position == 0){
|
tab_type.getTitleView(0).setTextSize(TypedValue.COMPLEX_UNIT_SP,16f)
|
tab_type.getTitleView(1).setTextSize(TypedValue.COMPLEX_UNIT_SP,14f)
|
}else{
|
tab_type.getTitleView(1).setTextSize(TypedValue.COMPLEX_UNIT_SP,16f)
|
tab_type.getTitleView(0).setTextSize(TypedValue.COMPLEX_UNIT_SP,14f)
|
}
|
}
|
|
override fun onTabReselect(position: Int) {
|
}
|
})
|
}
|
|
|
private var locCount = 0L //定位次数
|
private fun initMap() {
|
val myLocationStyle = MyLocationStyle()
|
myLocationStyle.strokeColor(resources.getColor(R.color.colorBrown))
|
myLocationStyle.radiusFillColor(resources.getColor(R.color.colorTransBrown))
|
myLocationStyle.interval(3000)
|
myLocationStyle.anchor(0.5f, 0.5f)
|
myLocationStyle.myLocationType(MyLocationStyle.LOCATION_TYPE_LOCATION_ROTATE_NO_CENTER)//
|
myLocationStyle.myLocationIcon(BitmapDescriptorFactory.fromResource(R.mipmap.icon_coordinate))
|
aMap.myLocationStyle = myLocationStyle//设置定位蓝点的Style
|
aMap.uiSettings.isMyLocationButtonEnabled = false//设置默认定位按钮是否显示,非必需设置。
|
aMap.uiSettings.setZoomInByScreenCenter(true)
|
aMap.uiSettings.isZoomControlsEnabled = false
|
aMap.uiSettings.isRotateGesturesEnabled = false
|
aMap.uiSettings.isTiltGesturesEnabled = false
|
aMap.isMyLocationEnabled = true
|
aMap.setOnMyLocationChangeListener {
|
it as Inner_3dMap_location
|
Log.e(Const.Tag, "出租车:lat:" + it.latitude + ",lon:" + it.longitude)
|
KuanzhaiApplication.lat = it.latitude
|
KuanzhaiApplication.lon = it.longitude
|
KuanzhaiApplication.address = it.address
|
KuanzhaiApplication.cityCode = it.extras.getString("adcode") ?: ""
|
if (locCount < 1) {
|
if (mainActivity.lat != 0.0)
|
aMap.animateCamera(
|
CameraUpdateFactory.newLatLngZoom(
|
LatLng(
|
mainActivity.lat,
|
mainActivity.lon
|
), 15f
|
)
|
)
|
else
|
aMap.animateCamera(
|
CameraUpdateFactory.newLatLngZoom(
|
LatLng(
|
it.latitude,
|
it.longitude
|
), 15f
|
)
|
)
|
}
|
locCount++
|
}
|
aMap.setOnCameraChangeListener(object : AMap.OnCameraChangeListener {
|
override fun onCameraChangeFinish(p0: CameraPosition?) {
|
if (!startByChoose && iv_center.visibility == View.VISIBLE) {
|
startLat = p0?.target?.latitude ?: 0.0
|
startLon = p0?.target?.longitude ?: 0.0
|
getPoi(startLat, startLon)
|
}
|
startByChoose = false
|
startByLocal = false
|
val objectAnimator =
|
ObjectAnimator.ofFloat(iv_center, "translationY", 0f, -30f, 0f).setDuration(600)
|
objectAnimator.start()
|
}
|
|
override fun onCameraChange(p0: CameraPosition?) {
|
|
}
|
})
|
}
|
|
/**
|
* 获取poi信息
|
*/
|
private var poiSearchDisposable: DisposableSubscriber<PoiResult>? = null
|
fun getPoi(lat: Double?, lng: Double?) {
|
if (lat == null || lng == null) {
|
return
|
}
|
//如果上一次还没处理完,取消订阅
|
if (poiSearchDisposable != null && !poiSearchDisposable!!.isDisposed) {
|
poiSearchDisposable?.dispose()
|
}
|
poiSearchDisposable = object : DisposableSubscriber<PoiResult>() {
|
override fun onComplete() {
|
|
}
|
|
override fun onNext(t: PoiResult?) {
|
val address = if (t != null) {
|
t.pois.sortBy { it.distance }
|
if (t.pois.isNotEmpty()) {
|
t.pois[0].title
|
} else {
|
null
|
}
|
} else {
|
null
|
}
|
runOnUiThread {
|
startName = address ?: ""
|
tv_start?.text = address
|
mainActivity.startName = startName
|
mainActivity.startLat = startLat
|
mainActivity.startLon = startLon
|
}
|
}
|
|
override fun onError(t: Throwable?) {
|
runOnUiThread {
|
startName = ""
|
tv_start.text = "点击选择起点"
|
}
|
}
|
}
|
val query = PoiSearch.Query("", "190000", "")
|
val poiSearch = PoiSearch(context, query)
|
poiSearch.bound = PoiSearch.SearchBound(LatLonPoint(lat, lng), 1000)
|
Flowable.just(poiSearch).ioScheduler().flatMap {
|
try {
|
val result = poiSearch.searchPOI()
|
if (result == null) {
|
Flowable.error(ResultException(""))
|
} else
|
Flowable.just(result)
|
} catch (e: Exception) {
|
e.printStackTrace()
|
Flowable.error<PoiResult>(e)
|
}
|
}.subscribe(poiSearchDisposable)
|
}
|
|
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
super.onActivityResult(requestCode, resultCode, data)
|
if (resultCode == Activity.RESULT_OK&&data!=null){
|
if (requestCode == 1){
|
startLat = data.getDoubleExtra("lat", 0.0)
|
startLon = data.getDoubleExtra("lon", 0.0)
|
startByChoose = true
|
aMap.animateCamera(CameraUpdateFactory.newLatLng(LatLng(startLat, startLon)))
|
startName = data.getStringExtra("name") ?: ""
|
tv_start.text = startName
|
showConfirmOrder()
|
}else if (requestCode == 2){
|
endLat = data.getDoubleExtra("lat", 0.0)
|
endLon = data.getDoubleExtra("lon", 0.0)
|
endName = data.getStringExtra("name") ?: ""
|
tv_end.text = endName
|
showConfirmOrder()
|
}else{
|
tv_way.text = "包车计费"
|
calType = 2
|
timeParam = data.getStringExtra("startTime")?:""
|
endTimeParam = data.getStringExtra("endTime")?:""
|
startName = data.getStringExtra("startName")?:""
|
tv_start.text = startName
|
startLat = data.getDoubleExtra("startLat",0.0)
|
startLon = data.getDoubleExtra("startLon",0.0)
|
endName = data.getStringExtra("endName")?:""
|
tv_end.text = endName
|
endLat = data.getDoubleExtra("endLat",0.0)
|
endLon = data.getDoubleExtra("endLon",0.0)
|
isNotice = if (data.getBooleanExtra("isRemind",false)) 1 else 0
|
passenger.clear()
|
passenger.addAll(data.getParcelableArrayListExtra("passenger")?: arrayListOf())
|
showConfirmOrder()
|
if (sc_type.visibility == View.VISIBLE) //之前请求过车型,现在可能订单参数发生变化
|
getCarType()
|
}
|
}
|
}
|
|
private fun showConfirmOrder(){
|
if (startLat!=0.0&&endLat!=0.0){
|
searchRoute(LatLonPoint(startLat, startLon), LatLonPoint(endLat, endLon))
|
iv_center.gone()
|
}
|
}
|
|
private fun searchRoute(start: LatLonPoint, end: LatLonPoint) {
|
val fromAndTo = RouteSearch.FromAndTo(start, end)
|
val driveRouteQuery =
|
RouteSearch.DriveRouteQuery(fromAndTo, RouteSearch.DrivingDefault, null, null, "")
|
val routeSearch = RouteSearch(mainActivity)
|
routeSearch.calculateDriveRouteAsyn(driveRouteQuery)
|
routeSearch.setRouteSearchListener(this)
|
}
|
|
fun back(){
|
tv_action.isEnabled = true
|
tv_end.text = ""
|
endLat = 0.0
|
endLon = 0.0
|
endName = ""
|
tv_time.text = "时间"
|
timeParam = ""
|
endTimeParam = ""
|
tv_reason.text = "事由出行"
|
drivingRouteOverlay?.removeFromMap()
|
startMarker?.remove()
|
endMarker?.remove()
|
aMap.animateCamera(
|
CameraUpdateFactory.newLatLngZoom(
|
LatLng(
|
KuanzhaiApplication.lat,
|
KuanzhaiApplication.lon
|
), 15f
|
)
|
)
|
passenger.clear()
|
mainActivity.updateTitleVisibility(false, false)
|
mainActivity.updateTipAlpha(1f)
|
sc_type.gone()
|
cl_1.visible()
|
tv_action.text = "确定"
|
calType = 0
|
tv_way.text = "计费方式"
|
}
|
|
fun checkPermission():Boolean{
|
if (!KuanzhaiApplication.officialPermission){
|
val alertDialog = TipDialog()
|
alertDialog.arguments = bundleOf("msg" to "未通过企业认证","ok" to "立即认证","isAlert" to true)
|
alertDialog.setCallback(object :TipDialog.OnClickCallback{
|
override fun onOk() {
|
HttpManager.queryCompany().requestByF(this@OfficialFragment){_,data->
|
startActivity<VerifyCompanyActivity>("data" to data)
|
}
|
}
|
|
override fun onCancel() {
|
}
|
})
|
alertDialog.show(childFragmentManager,"no")
|
}
|
return KuanzhaiApplication.officialPermission
|
}
|
|
override fun onCreate(savedInstanceState: Bundle?) {
|
super.onCreate(savedInstanceState)
|
this.savedInstanceState = savedInstanceState
|
}
|
|
override fun onResume() {
|
super.onResume()
|
mMapView.onResume()
|
}
|
|
override fun onPause() {
|
super.onPause()
|
mMapView.onPause()
|
}
|
|
override fun onDestroy() {
|
super.onDestroy()
|
mMapView.onDestroy()
|
EventBus.getDefault().unregister(this)
|
}
|
|
override fun onSaveInstanceState(outState: Bundle) {
|
super.onSaveInstanceState(outState)
|
mMapView.onSaveInstanceState(outState)
|
}
|
|
override fun onLowMemory() {
|
super.onLowMemory()
|
mMapView.onLowMemory()
|
}
|
|
override fun onBusRouteSearched(result: BusRouteResult?, errorCode: Int) {
|
}
|
|
override fun onDriveRouteSearched(result: DriveRouteResult?, errorCode: Int) {
|
if (errorCode == 1000) {
|
drivingRouteOverlay?.removeFromMap()
|
if (result?.paths != null) {
|
if (result.paths.size > 0) {
|
val drivePath = result.paths[0]
|
drivingRouteOverlay = DrivingRouteOverlay(
|
activity, aMap, drivePath,
|
result.startPos,
|
result.targetPos
|
)
|
drivingRouteOverlay!!.setNodeIconVisibility(false)
|
drivingRouteOverlay!!.addToMap(Color.parseColor("#00C47A"))
|
drivingRouteOverlay!!.zoomToSpan(40, 120, 40, 300)
|
val args = drivePath.duration / 60
|
setMarker(LatLng(startLat,startLon))
|
setMarker(
|
LatLng(endLat, endLon),
|
String.format("大约行驶%d分钟", if (args == 0L) 1 else args)
|
)
|
}
|
}
|
}
|
}
|
|
private var startMarker: Marker? = null
|
private var endMarker: Marker? = null
|
private fun setMarker(latLon: LatLng, content: String = "") {
|
val options = MarkerOptions()
|
options.position(latLon)
|
if (content.isNotEmpty()) {
|
val view = layoutInflater.inflate(R.layout.marker_with_text, null, false)
|
val contentView = view.findViewById(R.id.tv_content) as TextView
|
contentView.text = SpanBuilder(content).color(
|
mainActivity,
|
4,
|
content.length - 2,
|
R.color.colorPrimary
|
).build()
|
options.icon(BitmapDescriptorFactory.fromView(view))
|
startMarker = aMap.addMarker(options)
|
} else {
|
options.icon(BitmapDescriptorFactory.fromResource(R.mipmap.starting_point))
|
endMarker = aMap.addMarker(options)
|
}
|
}
|
|
override fun onWalkRouteSearched(p0: WalkRouteResult?, p1: Int) {
|
}
|
|
override fun onRideRouteSearched(p0: RideRouteResult?, p1: Int) {
|
}
|
}
|