增加车信提前看板显示
调整条件限速,常规限速提前看板,详细看板 调整道路名详细信息
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package com.navinfo.omqs.bean
|
||||
|
||||
import android.os.Parcelable
|
||||
import com.navinfo.collect.library.data.entity.RenderEntity
|
||||
import kotlinx.parcelize.Parcelize
|
||||
|
||||
@Parcelize
|
||||
@@ -11,20 +12,14 @@ data class SignBean(
|
||||
val distance: Int = 0,
|
||||
//左上图标中的文字
|
||||
val iconText: String = "",
|
||||
//绑定的要素id
|
||||
val elementId: String = "",
|
||||
//绑定的linkid
|
||||
val linkId: String,
|
||||
//坐标
|
||||
val geometry: String,
|
||||
//名称
|
||||
val name: String,
|
||||
//是否要展示详细信息
|
||||
val isMoreInfo: Boolean = false,
|
||||
//底部右侧文字
|
||||
val bottomRightText: String = "",
|
||||
//要素code类型
|
||||
val elementCode: Int,
|
||||
//需要展示更多的内容
|
||||
val moreText: String = "",
|
||||
//左上角信息
|
||||
val topRightText: String = ""
|
||||
//捕捉数据
|
||||
val renderEntity: RenderEntity
|
||||
) : Parcelable
|
||||
@@ -31,7 +31,7 @@ import com.navinfo.omqs.ui.activity.BaseActivity
|
||||
import com.navinfo.omqs.ui.fragment.console.ConsoleFragment
|
||||
import com.navinfo.omqs.ui.fragment.offlinemap.OfflineMapFragment
|
||||
import com.navinfo.omqs.ui.fragment.qsrecordlist.QsRecordListFragment
|
||||
import com.navinfo.omqs.ui.fragment.sign.RoadNameInfoFragment
|
||||
import com.navinfo.omqs.ui.fragment.signMoreInfo.SignMoreInfoFragment
|
||||
import com.navinfo.omqs.ui.fragment.tasklist.TaskManagerFragment
|
||||
import com.navinfo.omqs.ui.widget.RecyclerViewSpacesItemDecoration
|
||||
import com.navinfo.omqs.util.FlowEventBus
|
||||
@@ -61,7 +61,7 @@ class MainActivity : BaseActivity() {
|
||||
/**
|
||||
* 是否开启右侧面板
|
||||
*/
|
||||
var switchFragment = false
|
||||
private var switchFragment = false
|
||||
|
||||
/**
|
||||
* 检测是否含有tts插件
|
||||
@@ -90,6 +90,7 @@ class MainActivity : BaseActivity() {
|
||||
*/
|
||||
private val signAdapter by lazy {
|
||||
SignAdapter(object : OnSignAdapterClickListener {
|
||||
//点击看板进去问题反馈面板
|
||||
override fun onItemClick(signBean: SignBean) {
|
||||
rightController.currentDestination?.let {
|
||||
if (it.id == R.id.RightEmptyFragment) {
|
||||
@@ -101,14 +102,15 @@ class MainActivity : BaseActivity() {
|
||||
}
|
||||
}
|
||||
|
||||
//点击详细信息
|
||||
override fun onMoreInfoClick(selectTag: String, tag: String, signBean: SignBean) {
|
||||
if (binding.mainActivitySignMoreInfoGroup.visibility != View.VISIBLE || selectTag != tag) {
|
||||
binding.mainActivitySignMoreInfoGroup.visibility = View.VISIBLE
|
||||
binding.mainActivitySignMoreInfoTitle.text = signBean.name
|
||||
binding.mainActivitySignMoreInfoText1.text = signBean.bottomRightText
|
||||
binding.mainActivitySignMoreInfoText2.text = signBean.moreText
|
||||
} else {
|
||||
binding.mainActivitySignMoreInfoGroup.visibility = View.GONE
|
||||
viewModel.showSignMoreInfo(signBean.renderEntity)
|
||||
val fragment =
|
||||
supportFragmentManager.findFragmentById(R.id.main_activity_sign_more_info_fragment)
|
||||
if (fragment == null) {
|
||||
supportFragmentManager.beginTransaction()
|
||||
.replace(R.id.main_activity_sign_more_info_fragment, SignMoreInfoFragment())
|
||||
.commit()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -122,10 +124,6 @@ class MainActivity : BaseActivity() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onHideMoreInfoView() {
|
||||
binding.mainActivitySignMoreInfoGroup.visibility = View.GONE
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -200,13 +198,13 @@ class MainActivity : BaseActivity() {
|
||||
}
|
||||
//道路绑定,名称变化
|
||||
viewModel.liveDataRoadName.observe(this) {
|
||||
if (it != null && it.isNotEmpty()) {
|
||||
binding.mainActivityRoadName.text = it[0].name
|
||||
if (binding.mainActivityRoadName.visibility != View.VISIBLE)
|
||||
binding.mainActivityRoadName.visibility = View.VISIBLE
|
||||
if (it != null) {
|
||||
binding.mainActivityRoadName.text = it.properties["name"]
|
||||
if (binding.mainActivityRoadName.visibility != View.VISIBLE) binding.mainActivityRoadName.visibility =
|
||||
View.VISIBLE
|
||||
} else {
|
||||
if (binding.mainActivityRoadName.visibility != View.GONE)
|
||||
binding.mainActivityRoadName.visibility = View.GONE
|
||||
if (binding.mainActivityRoadName.visibility != View.GONE) binding.mainActivityRoadName.visibility =
|
||||
View.GONE
|
||||
}
|
||||
}
|
||||
|
||||
@@ -242,13 +240,11 @@ class MainActivity : BaseActivity() {
|
||||
|
||||
//监听地图中点变化
|
||||
viewModel.liveDataCenterPoint.observe(this) {
|
||||
Log.e("qj", "${it.longitude}")
|
||||
try {
|
||||
if (it != null && it.longitude != null && it.latitude != null) {
|
||||
binding.mainActivityGeometry.text = "经纬度:${
|
||||
BigDecimal(it.longitude).setScale(
|
||||
7,
|
||||
RoundingMode.HALF_UP
|
||||
7, RoundingMode.HALF_UP
|
||||
)
|
||||
},${BigDecimal(it.latitude).setScale(7, RoundingMode.HALF_UP)}"
|
||||
}
|
||||
@@ -257,6 +253,16 @@ class MainActivity : BaseActivity() {
|
||||
}
|
||||
}
|
||||
|
||||
viewModel.liveDataSignMoreInfo.observe(this){
|
||||
val fragment =
|
||||
supportFragmentManager.findFragmentById(R.id.main_activity_sign_more_info_fragment)
|
||||
if (fragment == null) {
|
||||
supportFragmentManager.beginTransaction()
|
||||
.replace(R.id.main_activity_sign_more_info_fragment, SignMoreInfoFragment())
|
||||
.commit()
|
||||
}
|
||||
}
|
||||
|
||||
lifecycleScope.launch {
|
||||
// 初始化地图图层控制接收器
|
||||
FlowEventBus.subscribe<List<ImportConfig>>(
|
||||
@@ -487,8 +493,7 @@ class MainActivity : BaseActivity() {
|
||||
}
|
||||
leftFragment = TaskManagerFragment {
|
||||
binding.mainActivityLeftFragment.visibility = View.GONE
|
||||
supportFragmentManager.beginTransaction()
|
||||
.remove(leftFragment!!).commit()
|
||||
supportFragmentManager.beginTransaction().remove(leftFragment!!).commit()
|
||||
leftFragment = null
|
||||
null
|
||||
}
|
||||
@@ -508,8 +513,7 @@ class MainActivity : BaseActivity() {
|
||||
}
|
||||
leftFragment = QsRecordListFragment {
|
||||
binding.mainActivityLeftFragment.visibility = View.GONE
|
||||
supportFragmentManager.beginTransaction()
|
||||
.remove(leftFragment!!).commit()
|
||||
supportFragmentManager.beginTransaction().remove(leftFragment!!).commit()
|
||||
leftFragment = null
|
||||
null
|
||||
}
|
||||
@@ -536,8 +540,7 @@ class MainActivity : BaseActivity() {
|
||||
}
|
||||
leftFragment = OfflineMapFragment {
|
||||
binding.mainActivityLeftFragment.visibility = View.GONE
|
||||
supportFragmentManager.beginTransaction()
|
||||
.remove(leftFragment!!).commit()
|
||||
supportFragmentManager.beginTransaction().remove(leftFragment!!).commit()
|
||||
leftFragment = null
|
||||
null
|
||||
}
|
||||
@@ -547,15 +550,11 @@ class MainActivity : BaseActivity() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 打开道路名称属性看板
|
||||
* 打开道路名称属性看板,选择的道路在viewmodel里记录,不用
|
||||
*/
|
||||
fun openRoadNameFragment() {
|
||||
val fragment =
|
||||
supportFragmentManager.findFragmentById(R.id.main_activity_sign_more_info_fragment)
|
||||
if (fragment !is RoadNameInfoFragment) {
|
||||
supportFragmentManager.beginTransaction()
|
||||
.replace(R.id.main_activity_sign_more_info_fragment, RoadNameInfoFragment())
|
||||
.commit()
|
||||
if (viewModel.liveDataRoadName.value != null) {
|
||||
viewModel.showSignMoreInfo(viewModel.liveDataRoadName.value!!)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -78,7 +78,13 @@ class MainViewModel @Inject constructor(
|
||||
val liveDataTopSignList = MutableLiveData<List<SignBean>>()
|
||||
|
||||
//道路名
|
||||
val liveDataRoadName = MutableLiveData<List<RoadNameBean>?>()
|
||||
val liveDataRoadName = MutableLiveData<RenderEntity?>()
|
||||
|
||||
/**
|
||||
* 当前选中的要展示的详细信息的要素
|
||||
*/
|
||||
val liveDataSignMoreInfo = MutableLiveData<RenderEntity>()
|
||||
|
||||
// var testPoint = GeoPoint(0, 0)
|
||||
|
||||
//uuid标识,用于记录轨迹组
|
||||
@@ -96,6 +102,7 @@ class MainViewModel @Inject constructor(
|
||||
|
||||
var menuState: Boolean = false
|
||||
|
||||
|
||||
val liveDataMenuState = MutableLiveData<Boolean>()
|
||||
|
||||
val liveDataCenterPoint = MutableLiveData<MapPosition>()
|
||||
@@ -236,7 +243,7 @@ class MainViewModel @Inject constructor(
|
||||
|
||||
if (element.code == 2011) {
|
||||
hisRoadName = true
|
||||
liveDataRoadName.postValue(SignUtil.getRoadNameList(element))
|
||||
liveDataRoadName.postValue(element)
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -248,20 +255,18 @@ class MainViewModel @Inject constructor(
|
||||
iconId = SignUtil.getSignIcon(element),
|
||||
iconText = SignUtil.getSignIconText(element),
|
||||
distance = distance.toInt(),
|
||||
elementId = element.id,
|
||||
linkId = linkId,
|
||||
geometry = element.geometry,
|
||||
name = SignUtil.getSignNameText(element),
|
||||
bottomRightText = SignUtil.getSignBottomRightText(element),
|
||||
elementCode = element.code,
|
||||
moreText = SignUtil.getMoreInfoText(element)
|
||||
renderEntity = element,
|
||||
isMoreInfo = SignUtil.isMoreInfo(element)
|
||||
)
|
||||
Log.e("jingo", "捕捉到的数据code ${element.code}")
|
||||
when (element.code) {
|
||||
2002, 2008, 2010, 2041 -> topSignList.add(
|
||||
signBean
|
||||
)
|
||||
4002, 4003, 4004, 4022 -> signList.add(
|
||||
4002, 4003, 4004, 4010, 4022, 4601 -> signList.add(
|
||||
signBean
|
||||
)
|
||||
}
|
||||
@@ -288,8 +293,8 @@ class MainViewModel @Inject constructor(
|
||||
}
|
||||
}
|
||||
|
||||
liveDataTopSignList.postValue(topSignList.distinctBy { it.elementCode })
|
||||
liveDataSignList.postValue(signList.distinctBy { it.elementCode })
|
||||
liveDataTopSignList.postValue(topSignList.distinctBy { it.distance })
|
||||
liveDataSignList.postValue(signList.sortedBy { it.distance })
|
||||
val speechText = SignUtil.getRoadSpeechText(topSignList)
|
||||
withContext(Dispatchers.Main) {
|
||||
speakMode?.speakText(speechText)
|
||||
@@ -495,8 +500,19 @@ class MainViewModel @Inject constructor(
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否开启了线选择
|
||||
*/
|
||||
fun isSelectRoad(): Boolean {
|
||||
return bSelectRoad
|
||||
}
|
||||
|
||||
/**
|
||||
* 要展示的要素详细信息
|
||||
*/
|
||||
|
||||
fun showSignMoreInfo(data: RenderEntity) {
|
||||
liveDataSignMoreInfo.value = data
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,63 +1,133 @@
|
||||
package com.navinfo.omqs.ui.activity.map
|
||||
|
||||
import android.graphics.PorterDuff
|
||||
import android.graphics.PorterDuffColorFilter
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.ImageView
|
||||
import com.navinfo.omqs.R
|
||||
import com.navinfo.omqs.bean.SignBean
|
||||
import com.navinfo.omqs.databinding.AdapterSignBinding
|
||||
import com.navinfo.omqs.databinding.AdapterSignLaneinfoBinding
|
||||
import com.navinfo.omqs.ui.other.BaseRecyclerViewAdapter
|
||||
import com.navinfo.omqs.ui.other.BaseViewHolder
|
||||
import com.navinfo.omqs.ui.widget.SignUtil
|
||||
|
||||
interface OnSignAdapterClickListener {
|
||||
fun onItemClick(signBean: SignBean)
|
||||
fun onMoreInfoClick(selectTag: String, tag: String, signBean: SignBean)
|
||||
fun onErrorClick(signBean: SignBean)
|
||||
fun onHideMoreInfoView()
|
||||
}
|
||||
|
||||
data class LaneInfoItem(val id: Int, val type: Int)
|
||||
|
||||
class SignAdapter(private var listener: OnSignAdapterClickListener?) :
|
||||
BaseRecyclerViewAdapter<SignBean>() {
|
||||
/**
|
||||
* 选中的详细信息按钮的tag标签
|
||||
*/
|
||||
private var selectMoreInfoTag: String = ""
|
||||
override fun getItemViewRes(position: Int): Int {
|
||||
return R.layout.adapter_sign
|
||||
|
||||
override fun getItemViewType(position: Int): Int {
|
||||
if (data.isNotEmpty() && data[position].renderEntity.code == 4601) {
|
||||
return 4601
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): BaseViewHolder {
|
||||
val viewBinding =
|
||||
AdapterSignBinding.inflate(LayoutInflater.from(parent.context), parent, false)
|
||||
return BaseViewHolder(viewBinding)
|
||||
return if (viewType == 4601) {
|
||||
val viewBinding =
|
||||
AdapterSignLaneinfoBinding.inflate(
|
||||
LayoutInflater.from(parent.context),
|
||||
parent,
|
||||
false
|
||||
)
|
||||
BaseViewHolder(viewBinding)
|
||||
} else {
|
||||
val viewBinding =
|
||||
AdapterSignBinding.inflate(LayoutInflater.from(parent.context), parent, false)
|
||||
BaseViewHolder(viewBinding)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: BaseViewHolder, position: Int) {
|
||||
val bd = holder.viewBinding as AdapterSignBinding
|
||||
|
||||
val context = holder.viewBinding.root.context
|
||||
val item = data[position]
|
||||
if (item.iconId != 0) bd.signMainIconBg.setImageResource(item.iconId)
|
||||
bd.signMainIcon.text = item.iconText
|
||||
bd.signBottomText.text = item.name
|
||||
holder.tag = item.name + position
|
||||
//点击错误按钮
|
||||
bd.signMainFastError.setOnClickListener {
|
||||
listener?.onErrorClick(item)
|
||||
}
|
||||
bd.signBottomRightText.text = item.bottomRightText
|
||||
if (holder.viewBinding is AdapterSignBinding) {
|
||||
val bd = holder.viewBinding
|
||||
|
||||
bd.root.setOnClickListener {
|
||||
if (item.iconId != 0) bd.signMainIconBg.setImageResource(item.iconId)
|
||||
bd.signMainIcon.text = item.iconText
|
||||
bd.signBottomText.text = item.name
|
||||
//点击错误按钮
|
||||
bd.signMainFastError.setOnClickListener {
|
||||
listener?.onErrorClick(item)
|
||||
}
|
||||
bd.signBottomRightText.text = item.bottomRightText
|
||||
if (item.isMoreInfo) {
|
||||
bd.signMainInfo.visibility = View.VISIBLE
|
||||
bd.signMainInfo.setOnClickListener {
|
||||
listener?.onMoreInfoClick(selectMoreInfoTag, holder.tag, item)
|
||||
selectMoreInfoTag = holder.tag
|
||||
}
|
||||
} else {
|
||||
bd.signMainInfo.visibility = View.GONE
|
||||
}
|
||||
bd.signSecondIcon.text = ""
|
||||
if (item.renderEntity.code == 4002) {
|
||||
val minSpeed = SignUtil.getSpeedLimitMinText(item.renderEntity)
|
||||
if (minSpeed != "0") {
|
||||
bd.signSecondIcon.text = minSpeed
|
||||
}
|
||||
}
|
||||
} else if (holder.viewBinding is AdapterSignLaneinfoBinding) {
|
||||
val bd = holder.viewBinding
|
||||
bd.signMoreIconsLayout.removeAllViews()
|
||||
bd.signBottomText.text = item.name
|
||||
bd.signBottomRightText.text = item.distance.toString()
|
||||
val list = SignUtil.getLineInfoIcons(item.renderEntity)
|
||||
val lineViewS = View(context)
|
||||
lineViewS.layoutParams = ViewGroup.LayoutParams(24, 80)
|
||||
lineViewS.background = context.getDrawable(R.drawable.shape_vertical_dashed_line)
|
||||
bd.signMoreIconsLayout.addView(lineViewS, lineViewS.layoutParams)
|
||||
for (i in list.indices) {
|
||||
val laneInfo = list[i]
|
||||
val imageView = ImageView(context)
|
||||
val drawable = context.getDrawable(laneInfo.id)
|
||||
var color = when (laneInfo.type) {
|
||||
1 -> bd.root.resources.getColor(R.color.lane_info_1)
|
||||
2 -> bd.root.resources.getColor(R.color.lane_info_2)
|
||||
else -> bd.root.resources.getColor(R.color.white)
|
||||
}
|
||||
// 创建 PorterDuffColorFilter 对象
|
||||
val colorFilter = PorterDuffColorFilter(color, PorterDuff.Mode.SRC_IN)
|
||||
// 将 PorterDuffColorFilter 设置给 Drawable
|
||||
drawable!!.colorFilter = colorFilter
|
||||
// 将 Drawable 设置给 ImageView
|
||||
imageView.background = drawable
|
||||
// 将 ImageView 的颜色设置为红色
|
||||
imageView.setColorFilter(color, PorterDuff.Mode.SRC_IN)
|
||||
imageView.layoutParams = ViewGroup.LayoutParams(35, 100)
|
||||
bd.signMoreIconsLayout.addView(imageView, imageView.layoutParams)
|
||||
if (i < list.size - 1) {
|
||||
val lineView = View(context)
|
||||
lineView.layoutParams = ViewGroup.LayoutParams(24, 80)
|
||||
lineView.background = context.getDrawable(R.drawable.shape_vertical_dashed_line)
|
||||
bd.signMoreIconsLayout.addView(lineView, lineView.layoutParams)
|
||||
}
|
||||
}
|
||||
val lineViewE = View(context)
|
||||
lineViewE.layoutParams = ViewGroup.LayoutParams(24, 80)
|
||||
lineViewE.background = context.getDrawable(R.drawable.shape_vertical_dashed_line)
|
||||
bd.signMoreIconsLayout.addView(lineViewE, lineViewE.layoutParams)
|
||||
}
|
||||
holder.viewBinding.root.setOnClickListener {
|
||||
listener?.onItemClick(item)
|
||||
}
|
||||
if (item.moreText.isNotEmpty()) {
|
||||
bd.signMainInfo.visibility = View.VISIBLE
|
||||
//点击更多信息按钮
|
||||
bd.signMainInfo.setOnClickListener {
|
||||
listener?.onMoreInfoClick(selectMoreInfoTag, holder.tag, item)
|
||||
selectMoreInfoTag = holder.tag
|
||||
}
|
||||
} else bd.signMainInfo.visibility = View.GONE
|
||||
|
||||
holder.tag = item.name + position
|
||||
}
|
||||
|
||||
override fun refreshData(newData: List<SignBean>) {
|
||||
@@ -67,7 +137,6 @@ class SignAdapter(private var listener: OnSignAdapterClickListener?) :
|
||||
return
|
||||
}
|
||||
}
|
||||
listener?.onHideMoreInfoView()
|
||||
}
|
||||
|
||||
}
|
||||
@@ -11,9 +11,6 @@ import com.navinfo.omqs.ui.other.BaseViewHolder
|
||||
|
||||
class TopSignAdapter(private var itemListener: ((Int, SignBean) -> Unit?)? = null) :
|
||||
BaseRecyclerViewAdapter<SignBean>() {
|
||||
override fun getItemViewRes(position: Int): Int {
|
||||
return R.layout.adapter_top_sign
|
||||
}
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): BaseViewHolder {
|
||||
val viewBinding =
|
||||
|
||||
@@ -1,13 +1,8 @@
|
||||
package com.navinfo.omqs.ui.fragment
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.KeyEvent
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.activity.OnBackPressedCallback
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.navigation.fragment.findNavController
|
||||
|
||||
abstract class BaseFragment : Fragment() {
|
||||
// override fun onCreateView(
|
||||
@@ -49,7 +44,7 @@ abstract class BaseFragment : Fragment() {
|
||||
// savedInstanceState: Bundle?
|
||||
// ): View
|
||||
|
||||
fun onBackPressed(): Boolean{
|
||||
open fun onBackPressed(): Boolean{
|
||||
// findNavController().navigateUp()
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ import com.navinfo.omqs.ui.fragment.BaseFragment
|
||||
import com.navinfo.omqs.ui.other.shareViewModels
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
import androidx.navigation.findNavController
|
||||
import androidx.navigation.fragment.findNavController
|
||||
import com.navinfo.omqs.ui.dialog.FirstDialog
|
||||
|
||||
@AndroidEntryPoint
|
||||
@@ -70,12 +71,12 @@ class EvaluationResultFragment : BaseFragment(), View.OnClickListener {
|
||||
val mDialog = FirstDialog(context)
|
||||
mDialog.setTitle("提示?")
|
||||
mDialog.setMessage("是否退出,请确认!")
|
||||
mDialog.setPositiveButton("确定", object : FirstDialog.OnClickListener {
|
||||
override fun onClick(dialog: Dialog?, which: Int) {
|
||||
mDialog.dismiss()
|
||||
onBackPressed()
|
||||
}
|
||||
})
|
||||
mDialog.setPositiveButton(
|
||||
"确定"
|
||||
) { _, _ ->
|
||||
mDialog.dismiss()
|
||||
onBackPressed()
|
||||
}
|
||||
mDialog.setNegativeButton("取消", null)
|
||||
mDialog.show()
|
||||
}
|
||||
@@ -315,4 +316,9 @@ class EvaluationResultFragment : BaseFragment(), View.OnClickListener {
|
||||
}
|
||||
}
|
||||
|
||||
override fun onBackPressed(): Boolean {
|
||||
findNavController().navigateUp()
|
||||
return true
|
||||
}
|
||||
|
||||
}
|
||||
@@ -137,7 +137,7 @@ class EvaluationResultViewModel @Inject constructor(
|
||||
}
|
||||
} else {
|
||||
liveDataQsRecordBean.value?.run {
|
||||
elementId = bean.elementId
|
||||
elementId = bean.renderEntity.code.toString()
|
||||
linkId = bean.linkId
|
||||
if (linkId.isNotEmpty()) {
|
||||
viewModelScope.launch {
|
||||
@@ -149,7 +149,7 @@ class EvaluationResultViewModel @Inject constructor(
|
||||
}
|
||||
}
|
||||
}
|
||||
val point = GeometryTools.createGeoPoint(bean.geometry)
|
||||
val point = GeometryTools.createGeoPoint(bean.renderEntity.geometry)
|
||||
this.geometry = GeometryTools.createGeometry(point).toText()
|
||||
mapController.animationHandler.animationByLatLon(point.latitude, point.longitude)
|
||||
mapController.markerHandle.addMarker(point, markerTitle)
|
||||
@@ -198,7 +198,7 @@ class EvaluationResultViewModel @Inject constructor(
|
||||
liveDataLeftTypeList.postValue(it)
|
||||
if (bean != null) {
|
||||
val classType2 = roomAppDatabase.getScProblemTypeDao()
|
||||
.findClassTypeByCode(bean.elementCode)
|
||||
.findClassTypeByCode(bean.renderEntity.code)
|
||||
if (classType2 != null) {
|
||||
classType = classType2
|
||||
}
|
||||
|
||||
@@ -13,9 +13,6 @@ class LeftAdapter(private var itemListener: ((Int, String) -> Unit?)? = null) :
|
||||
BaseRecyclerViewAdapter<String>() {
|
||||
private var selectTitle = ""
|
||||
|
||||
override fun getItemViewRes(position: Int): Int {
|
||||
return R.layout.text_item_select
|
||||
}
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): BaseViewHolder {
|
||||
val viewBinding =
|
||||
|
||||
@@ -13,9 +13,6 @@ class MiddleAdapter(private var itemListener: ((Int, String) -> Unit?)? = null)
|
||||
BaseRecyclerViewAdapter<String>() {
|
||||
private var selectTitle = ""
|
||||
|
||||
override fun getItemViewRes(position: Int): Int {
|
||||
return R.layout.text_item_select
|
||||
}
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): BaseViewHolder {
|
||||
val viewBinding =
|
||||
|
||||
@@ -11,9 +11,6 @@ class RightGroupHeaderAdapter(private var itemListener: ((Int, RightBean) -> Uni
|
||||
BaseRecyclerViewAdapter<RightBean>() {
|
||||
private var selectTitle = ""
|
||||
private var groupTitleList = mutableListOf<String>()
|
||||
override fun getItemViewRes(position: Int): Int {
|
||||
return R.layout.text_item_select2
|
||||
}
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): BaseViewHolder {
|
||||
val viewBinding =
|
||||
|
||||
@@ -224,10 +224,6 @@ class SoundtListAdapter(
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
override fun getItemViewRes(position: Int): Int {
|
||||
return R.layout.adapter_sound_list
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -131,10 +131,6 @@ class OfflineMapCityListAdapter(
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun getItemViewRes(position: Int): Int {
|
||||
return R.layout.adapter_offline_map_city
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -58,9 +58,6 @@ class QsRecordListAdapter(
|
||||
binding.qsRecordTime.text = qsRecordBean.checkTime
|
||||
}
|
||||
|
||||
override fun getItemViewRes(position: Int): Int {
|
||||
return R.layout.adapter_qs_record_list
|
||||
}
|
||||
|
||||
// 提供set方法
|
||||
fun setOnKotlinItemClickListener(itemClickListener: IKotlinItemClickListener) {
|
||||
|
||||
@@ -1,57 +0,0 @@
|
||||
package com.navinfo.omqs.ui.fragment.sign
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.fragment.app.activityViewModels
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import com.navinfo.omqs.databinding.FragmentSignRoadnameBinding
|
||||
import com.navinfo.omqs.ui.activity.map.MainViewModel
|
||||
import com.navinfo.omqs.ui.fragment.BaseFragment
|
||||
|
||||
|
||||
class RoadNameInfoFragment : BaseFragment() {
|
||||
private var _binding: FragmentSignRoadnameBinding? = null
|
||||
private val binding get() = _binding!!
|
||||
|
||||
private val viewModel by activityViewModels<MainViewModel>()
|
||||
private val adapter by lazy { RoadNameInfoAdapter() }
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?
|
||||
): View {
|
||||
_binding = FragmentSignRoadnameBinding.inflate(inflater, container, false)
|
||||
return binding.root
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
|
||||
val layoutManager = LinearLayoutManager(context)
|
||||
//// 设置 RecyclerView 的固定大小,避免在滚动时重新计算视图大小和布局,提高性能
|
||||
binding.roadnameRecyclerview.setHasFixedSize(true)
|
||||
binding.roadnameRecyclerview.layoutManager = layoutManager
|
||||
binding.roadnameRecyclerview.adapter = adapter
|
||||
viewModel.liveDataRoadName.observe(viewLifecycleOwner) {
|
||||
if (it != null && it.isNotEmpty()) {
|
||||
adapter.refreshData(it)
|
||||
} else {
|
||||
activity?.run {
|
||||
supportFragmentManager.beginTransaction().remove(this@RoadNameInfoFragment)
|
||||
.commit()
|
||||
}
|
||||
}
|
||||
}
|
||||
binding.roadnameCancel.setOnClickListener {
|
||||
activity?.run {
|
||||
supportFragmentManager.beginTransaction().remove(this@RoadNameInfoFragment)
|
||||
.commit()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onDestroyView() {
|
||||
super.onDestroyView()
|
||||
_binding = null
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.navinfo.omqs.ui.fragment.signMoreInfo
|
||||
|
||||
import android.view.LayoutInflater
|
||||
import android.view.ViewGroup
|
||||
import com.navinfo.omqs.R
|
||||
import com.navinfo.omqs.databinding.AdapterElectronicEyeBinding
|
||||
import com.navinfo.omqs.ui.other.BaseRecyclerViewAdapter
|
||||
import com.navinfo.omqs.ui.other.BaseViewHolder
|
||||
|
||||
data class ElectronicEyeMoreInfoAdapterItem(
|
||||
val title: String,
|
||||
val text: String
|
||||
)
|
||||
|
||||
class ElectronicEyeInfoAdapter : BaseRecyclerViewAdapter<ElectronicEyeMoreInfoAdapterItem>() {
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): BaseViewHolder {
|
||||
val viewBinding =
|
||||
AdapterElectronicEyeBinding.inflate(LayoutInflater.from(parent.context), parent, false)
|
||||
return BaseViewHolder(viewBinding)
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: BaseViewHolder, position: Int) {
|
||||
val binding: AdapterElectronicEyeBinding =
|
||||
holder.viewBinding as AdapterElectronicEyeBinding
|
||||
val item = data[position]
|
||||
binding.title.text = item.title
|
||||
binding.text.text = item.text
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.navinfo.omqs.ui.fragment.sign
|
||||
package com.navinfo.omqs.ui.fragment.signMoreInfo
|
||||
|
||||
import android.view.LayoutInflater
|
||||
import android.view.ViewGroup
|
||||
@@ -9,9 +9,6 @@ import com.navinfo.omqs.ui.other.BaseRecyclerViewAdapter
|
||||
import com.navinfo.omqs.ui.other.BaseViewHolder
|
||||
|
||||
class RoadNameInfoAdapter : BaseRecyclerViewAdapter<RoadNameBean>() {
|
||||
override fun getItemViewRes(position: Int): Int {
|
||||
return R.layout.adapter_road_name
|
||||
}
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): BaseViewHolder {
|
||||
val viewBinding =
|
||||
@@ -0,0 +1,100 @@
|
||||
package com.navinfo.omqs.ui.fragment.signMoreInfo
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.fragment.app.activityViewModels
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import com.navinfo.omqs.R
|
||||
import com.navinfo.omqs.databinding.FragmentSignInfoBinding
|
||||
import com.navinfo.omqs.ui.activity.map.MainViewModel
|
||||
import com.navinfo.omqs.ui.fragment.BaseFragment
|
||||
import com.navinfo.omqs.ui.widget.SignUtil
|
||||
|
||||
|
||||
class SignMoreInfoFragment : BaseFragment() {
|
||||
private var _binding: FragmentSignInfoBinding? = null
|
||||
private val binding get() = _binding!!
|
||||
|
||||
private val viewModel by activityViewModels<MainViewModel>()
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?
|
||||
): View {
|
||||
_binding = FragmentSignInfoBinding.inflate(inflater, container, false)
|
||||
return binding.root
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
|
||||
val layoutManager = LinearLayoutManager(context)
|
||||
//// 设置 RecyclerView 的固定大小,避免在滚动时重新计算视图大小和布局,提高性能
|
||||
binding.signInfoRecyclerview.setHasFixedSize(true)
|
||||
binding.signInfoRecyclerview.layoutManager = layoutManager
|
||||
viewModel.liveDataSignMoreInfo.observe(viewLifecycleOwner) {
|
||||
binding.signInfoTitle.text = it.name
|
||||
val drawable = resources.getDrawable(R.drawable.icon_main_moreinfo_text_left, null);
|
||||
drawable.setBounds(
|
||||
0,
|
||||
0,
|
||||
drawable.minimumWidth,
|
||||
drawable.minimumHeight
|
||||
);//必须设置图片大小,否则不显示
|
||||
binding.signInfoTitle.setCompoundDrawables(
|
||||
drawable, null, null, null
|
||||
)
|
||||
|
||||
when (it.code) {
|
||||
//道路名
|
||||
2011 -> {
|
||||
val adapter = RoadNameInfoAdapter()
|
||||
binding.signInfoRecyclerview.adapter = adapter
|
||||
adapter.refreshData(SignUtil.getRoadNameList(it))
|
||||
}
|
||||
//常规点限速
|
||||
4002->{
|
||||
val adapter = ElectronicEyeInfoAdapter()
|
||||
binding.signInfoRecyclerview.adapter = adapter
|
||||
adapter.refreshData(SignUtil.getSpeedLimitMoreInfoText(it))
|
||||
}
|
||||
//条件点限速
|
||||
4003 -> {
|
||||
val adapter = ElectronicEyeInfoAdapter()
|
||||
binding.signInfoRecyclerview.adapter = adapter
|
||||
adapter.refreshData(SignUtil.getConditionLimitMoreInfoText(it))
|
||||
}
|
||||
//电子眼
|
||||
4010
|
||||
-> {
|
||||
val drawable = resources.getDrawable(R.drawable.icon_electronic_eye_left, null);
|
||||
drawable.setBounds(
|
||||
0,
|
||||
0,
|
||||
drawable.minimumWidth,
|
||||
drawable.minimumHeight
|
||||
);//必须设置图片大小,否则不显示
|
||||
binding.signInfoTitle.setCompoundDrawables(
|
||||
drawable, null, null, null
|
||||
)
|
||||
val adapter = ElectronicEyeInfoAdapter()
|
||||
binding.signInfoRecyclerview.adapter = adapter
|
||||
adapter.refreshData(SignUtil.getElectronicEyeMoreInfo(it))
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
binding.signInfoCancel.setOnClickListener {
|
||||
activity?.run {
|
||||
supportFragmentManager.beginTransaction().remove(this@SignMoreInfoFragment)
|
||||
.commit()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onDestroyView() {
|
||||
super.onDestroyView()
|
||||
_binding = null
|
||||
}
|
||||
}
|
||||
@@ -58,9 +58,6 @@ class TaskAdapter(
|
||||
}
|
||||
}
|
||||
|
||||
override fun getItemViewRes(position: Int): Int {
|
||||
return R.layout.adapter_task
|
||||
}
|
||||
|
||||
fun resetSelect() {
|
||||
selectPosition = -1
|
||||
|
||||
@@ -282,10 +282,6 @@ class TaskListAdapter(
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun getItemViewRes(position: Int): Int {
|
||||
return R.layout.adapter_task_list
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,11 +1,6 @@
|
||||
package com.navinfo.omqs.ui.other
|
||||
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View.OnClickListener
|
||||
import android.view.ViewGroup
|
||||
import androidx.databinding.DataBindingUtil
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.navinfo.omqs.R
|
||||
|
||||
/**
|
||||
* RecyclerView 适配器基础类
|
||||
@@ -27,10 +22,10 @@ abstract class BaseRecyclerViewAdapter<T>(var data: List<T> = listOf()) :
|
||||
// )
|
||||
// }
|
||||
|
||||
abstract fun getItemViewRes(position: Int): Int
|
||||
|
||||
override fun getItemViewType(position: Int): Int {
|
||||
return getItemViewRes(position)
|
||||
// abstract fun getItemViewRes(position: Int): Int
|
||||
//
|
||||
open override fun getItemViewType(position: Int): Int {
|
||||
return 0
|
||||
}
|
||||
|
||||
override fun getItemCount(): Int {
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
package com.navinfo.omqs.ui.widget
|
||||
|
||||
import android.util.Log
|
||||
import com.google.gson.Gson
|
||||
import com.navinfo.collect.library.data.entity.RenderEntity
|
||||
import com.navinfo.omqs.R
|
||||
import com.navinfo.omqs.bean.RoadNameBean
|
||||
import com.navinfo.omqs.bean.SignBean
|
||||
import com.navinfo.omqs.ui.activity.map.LaneInfoItem
|
||||
import com.navinfo.omqs.ui.fragment.signMoreInfo.ElectronicEyeMoreInfoAdapterItem
|
||||
import org.json.JSONArray
|
||||
import java.lang.reflect.Field
|
||||
|
||||
class SignUtil {
|
||||
companion object {
|
||||
@@ -25,7 +27,7 @@ class SignUtil {
|
||||
//车道数
|
||||
2041 -> getLaneNumText(data)
|
||||
//常规点限速,条件点限速
|
||||
4002, 4003 -> getSpeedLimitText(data)
|
||||
4002, 4003 -> getSpeedLimitMaxText(data)
|
||||
else -> ""
|
||||
}
|
||||
}
|
||||
@@ -79,8 +81,12 @@ class SignUtil {
|
||||
4004 -> "可变点限速"
|
||||
//普通交限
|
||||
4006 -> "普通交限"
|
||||
//电子眼
|
||||
4010 -> "电子眼"
|
||||
//交通灯
|
||||
4022 -> "交通灯"
|
||||
//交限
|
||||
4601 -> "车信"
|
||||
else -> ""
|
||||
}
|
||||
}
|
||||
@@ -96,24 +102,45 @@ class SignUtil {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 更多信息展示文字
|
||||
*/
|
||||
fun getMoreInfoText(data: RenderEntity): String {
|
||||
return when (data.code) {
|
||||
//条件点限速
|
||||
4003 -> getConditionLimitMoreInfoText(data)
|
||||
else -> ""
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 条件点限速更多信息
|
||||
*/
|
||||
private fun getConditionLimitMoreInfoText(data: RenderEntity): String {
|
||||
return data.properties["validPeriod"].toString()
|
||||
fun getConditionLimitMoreInfoText(renderEntity: RenderEntity): List<ElectronicEyeMoreInfoAdapterItem> {
|
||||
|
||||
val list = mutableListOf<ElectronicEyeMoreInfoAdapterItem>()
|
||||
val maxSpeed = renderEntity.properties["maxSpeed"]
|
||||
if (maxSpeed != null) {
|
||||
list.add(
|
||||
ElectronicEyeMoreInfoAdapterItem(
|
||||
title = "最高限速值(km/h)", text = maxSpeed
|
||||
)
|
||||
)
|
||||
}
|
||||
list.add(
|
||||
ElectronicEyeMoreInfoAdapterItem(
|
||||
title = "限速条件", text = getConditionLimitText(renderEntity)
|
||||
)
|
||||
)
|
||||
val carType = renderEntity.properties["vehicleType"]
|
||||
if (carType != "0") {
|
||||
list.add(
|
||||
ElectronicEyeMoreInfoAdapterItem(
|
||||
title = "车辆类型", text = getElectronicEyeVehicleType(carType!!.toInt())
|
||||
)
|
||||
)
|
||||
}
|
||||
val time = renderEntity.properties["validPeriod"]
|
||||
if (time?.isNotEmpty() == true) {
|
||||
list.add(
|
||||
ElectronicEyeMoreInfoAdapterItem(
|
||||
title = "时间段", text = time
|
||||
)
|
||||
)
|
||||
}
|
||||
return list
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 条件点限速文字
|
||||
*/
|
||||
@@ -163,21 +190,31 @@ class SignUtil {
|
||||
/**
|
||||
* 获取限速值文字
|
||||
*/
|
||||
private fun getSpeedLimitText(data: RenderEntity): String {
|
||||
private fun getSpeedLimitMaxText(data: RenderEntity): String {
|
||||
try {
|
||||
//限速标志 0 限速开始 1 限速解除
|
||||
val maxSpeed = data.properties["maxSpeed"]
|
||||
val minSpeed = data.properties["minSpeed"]
|
||||
return if (maxSpeed != "0")
|
||||
maxSpeed.toString()
|
||||
else
|
||||
minSpeed.toString()
|
||||
return maxSpeed.toString()
|
||||
} catch (e: Exception) {
|
||||
Log.e("jingo", "获取限速面板ICON出错1 $e")
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取限速值文字
|
||||
*/
|
||||
fun getSpeedLimitMinText(data: RenderEntity): String {
|
||||
try {
|
||||
//限速标志 0 限速开始 1 限速解除
|
||||
val minSpeed = data.properties["minSpeed"]
|
||||
return minSpeed.toString()
|
||||
} catch (e: Exception) {
|
||||
Log.e("jingo", "获取限速面板ICON出错1 $e")
|
||||
}
|
||||
return "0"
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取种别名称
|
||||
*/
|
||||
@@ -185,6 +222,25 @@ class SignUtil {
|
||||
return data.properties["kind"].toString()
|
||||
}
|
||||
|
||||
/**
|
||||
* 常规点限速更多信息
|
||||
*/
|
||||
fun getSpeedLimitMoreInfoText(renderEntity: RenderEntity): List<ElectronicEyeMoreInfoAdapterItem> {
|
||||
|
||||
val list = mutableListOf<ElectronicEyeMoreInfoAdapterItem>()
|
||||
list.add(
|
||||
ElectronicEyeMoreInfoAdapterItem(
|
||||
title = "最高限速值(km/h)", text = getSpeedLimitMaxText(renderEntity)
|
||||
)
|
||||
)
|
||||
list.add(
|
||||
ElectronicEyeMoreInfoAdapterItem(
|
||||
title = "最低限速值(km/h)", text = getSpeedLimitMinText(renderEntity)
|
||||
)
|
||||
)
|
||||
return list
|
||||
}
|
||||
|
||||
/**
|
||||
* 限速图标
|
||||
*/
|
||||
@@ -235,6 +291,8 @@ class SignUtil {
|
||||
4003 -> getConditionalSpeedLimitIcon(data)
|
||||
//可变点限速
|
||||
4004 -> R.drawable.icon_change_limit
|
||||
//电子眼
|
||||
4010 -> R.drawable.icon_electronic_eye
|
||||
//交通灯
|
||||
4022 -> R.drawable.icon_traffic_light
|
||||
else -> 0
|
||||
@@ -318,12 +376,11 @@ class SignUtil {
|
||||
* 获取道路播报语音文字
|
||||
*/
|
||||
fun getRoadSpeechText(topSignList: MutableList<SignBean>): String {
|
||||
if (topSignList.size == 0)
|
||||
return ""
|
||||
if (topSignList.size == 0) return ""
|
||||
val stringBuffer = StringBuffer()
|
||||
stringBuffer.append("当前道路")
|
||||
for (item in topSignList) {
|
||||
when (item.elementCode) {
|
||||
when (item.renderEntity.code) {
|
||||
2002 -> stringBuffer.append("功能等级${item.iconText.substring(2)}级,")
|
||||
2008 -> stringBuffer.append("种别${item.iconText},")
|
||||
2010 -> stringBuffer.append("${item.iconText},")
|
||||
@@ -347,10 +404,7 @@ class SignUtil {
|
||||
val seqNum = jsonObject.optInt("seqNum", 1)
|
||||
val nameClass = jsonObject.optInt("nameClass", 1)
|
||||
val bean = RoadNameBean(
|
||||
name = name,
|
||||
type = type,
|
||||
seqNum = seqNum,
|
||||
nameClass = nameClass
|
||||
name = name, type = type, seqNum = seqNum, nameClass = nameClass
|
||||
)
|
||||
list.add(bean)
|
||||
}
|
||||
@@ -370,5 +424,195 @@ class SignUtil {
|
||||
}
|
||||
return list
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否要有详细信息需要展示
|
||||
*/
|
||||
fun isMoreInfo(element: RenderEntity): Boolean {
|
||||
val isMore = when (element.code) {
|
||||
//常规点限速
|
||||
4002 -> getSpeedLimitMinText(element) != "0"
|
||||
//条件点限速
|
||||
4003 -> true
|
||||
//电子眼
|
||||
4010 -> true
|
||||
else -> false
|
||||
}
|
||||
Log.e("jingo", "更多信息:${element.code} $isMore")
|
||||
return isMore
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取电子眼详细信息
|
||||
*/
|
||||
fun getElectronicEyeMoreInfo(renderEntity: RenderEntity): List<ElectronicEyeMoreInfoAdapterItem> {
|
||||
val list = mutableListOf<ElectronicEyeMoreInfoAdapterItem>()
|
||||
val kindCode = renderEntity.properties["kind"]!!.toInt()
|
||||
val kind = ElectronicEyeMoreInfoAdapterItem(
|
||||
title = "电子眼类型", text = getElectronicEyeKindType(kindCode)
|
||||
)
|
||||
list.add(kind)
|
||||
when (kindCode) {
|
||||
1, 2, 3, 4, 5, 6, 20, 21 -> {
|
||||
list.add(
|
||||
ElectronicEyeMoreInfoAdapterItem(
|
||||
title = "限速值(km/h)",
|
||||
text = renderEntity.properties["speedLimit"].toString()
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
val carType = renderEntity.properties["vehicleType"]
|
||||
if (carType != null && carType != "0") {
|
||||
list.add(
|
||||
ElectronicEyeMoreInfoAdapterItem(
|
||||
title = "车辆类型",
|
||||
text = getElectronicEyeVehicleType(carType.toInt())
|
||||
)
|
||||
)
|
||||
}
|
||||
val time = renderEntity.properties["validPeriod"]
|
||||
if (time?.isNotEmpty() == true) {
|
||||
list.add(
|
||||
ElectronicEyeMoreInfoAdapterItem(
|
||||
title = "时间段", text = time
|
||||
)
|
||||
)
|
||||
}
|
||||
if (kindCode == 20 || kindCode == 21) {
|
||||
list.add(
|
||||
ElectronicEyeMoreInfoAdapterItem(
|
||||
title = "区间测试配对", text = renderEntity.properties["pairEleceyeId"].toString()
|
||||
)
|
||||
)
|
||||
}
|
||||
return list
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取电子眼车辆类型
|
||||
*/
|
||||
private fun getElectronicEyeVehicleType(type: Int): String {
|
||||
var stringBuffer = StringBuffer()
|
||||
for (i in 31 downTo 0) {
|
||||
val bit = (type shr i) and 1
|
||||
if (bit == 1) {
|
||||
when (i) {
|
||||
0 -> stringBuffer.append("其他 ")
|
||||
1 -> stringBuffer.append("小汽车 ")
|
||||
2 -> stringBuffer.append("公交车 ")
|
||||
3 -> stringBuffer.append("多人乘坐车辆 ")
|
||||
4 -> stringBuffer.append("配送车 ")
|
||||
5 -> stringBuffer.append("摩托车 ")
|
||||
6 -> stringBuffer.append("行人 ")
|
||||
7 -> stringBuffer.append("自行车 ")
|
||||
8 -> stringBuffer.append("出租车 ")
|
||||
10 -> stringBuffer.append("紧急车辆 ")
|
||||
11 -> stringBuffer.append("运输卡车 ")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return stringBuffer.toString()
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取电子眼类型
|
||||
*/
|
||||
private fun getElectronicEyeKindType(kind: Int): String {
|
||||
return when (kind) {
|
||||
0 -> "未调查"
|
||||
1 -> "超高速"
|
||||
2 -> "超低速"
|
||||
3 -> "移动式测速"
|
||||
4 -> "可变限速"
|
||||
5 -> "分车道限速"
|
||||
6 -> "分车种限速"
|
||||
7 -> "违规用灯"
|
||||
8 -> "违规占车道"
|
||||
9 -> "违规过路口"
|
||||
10 -> "机动车闯红灯"
|
||||
11 -> "路况监控"
|
||||
12 -> "单行线"
|
||||
13 -> "占用非机动车道"
|
||||
14 -> "出入口"
|
||||
15 -> "占用公交车专用道"
|
||||
16 -> "禁止左右转"
|
||||
17 -> "禁止掉头"
|
||||
18 -> "占用应急车道"
|
||||
19 -> "违反禁止标线"
|
||||
20 -> "区间测速开始"
|
||||
21 -> "区间测速结束"
|
||||
22 -> "违章停车"
|
||||
23 -> "尾号限行"
|
||||
24 -> "环保限行"
|
||||
25 -> "不系安全带"
|
||||
26 -> "开车打手机"
|
||||
27 -> "礼让行人"
|
||||
28 -> "违反禁令标志"
|
||||
29 -> "禁止鸣笛"
|
||||
30 -> "车辆未按规定年检"
|
||||
31 -> "车辆尾气超标"
|
||||
32 -> "ETC拍照计费电子眼"
|
||||
33 -> "专用车道电子眼预留"
|
||||
34 -> "交通标线电子眼预留"
|
||||
35 -> "违章电子眼预留"
|
||||
36 -> "卡车超限电子眼"
|
||||
37 -> "限时长停车电子眼"
|
||||
else -> "无效类型"
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取车信图标
|
||||
*/
|
||||
fun getLineInfoIcons(renderEntity: RenderEntity): List<LaneInfoItem> {
|
||||
val list = mutableListOf<LaneInfoItem>()
|
||||
try {
|
||||
var laneinfoGroup = renderEntity.properties["laneinfoGroup"]
|
||||
if (laneinfoGroup != null) {
|
||||
laneinfoGroup = laneinfoGroup.substring(1, laneinfoGroup.length - 1)
|
||||
laneinfoGroup = "[$laneinfoGroup]"
|
||||
}
|
||||
val jsonArray = JSONArray(laneinfoGroup)
|
||||
if (jsonArray.length() == 2) {
|
||||
val itemArray = jsonArray[0]
|
||||
val typeArray = jsonArray[1]
|
||||
if ((itemArray is JSONArray) && (typeArray is JSONArray) && itemArray.length() == typeArray.length()) {
|
||||
for (i in 0 until itemArray.length()) {
|
||||
val itemObject = itemArray[i]
|
||||
val type = typeArray[i]
|
||||
var laneInfo = "laneinfo_${itemObject.toString().replace(",", "_")}"
|
||||
Log.e("jingo", "车信图标 $laneInfo")
|
||||
list.add(
|
||||
LaneInfoItem(
|
||||
id = getResId(
|
||||
laneInfo, R.drawable::class.java
|
||||
), type = type!!.toString().toInt()
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} catch (e: Exception) {
|
||||
Log.e("jingo", "json 解析失败")
|
||||
}
|
||||
return list
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过字符串名称获取资源id
|
||||
*/
|
||||
private fun getResId(variableName: String, c: Class<*>): Int {
|
||||
return try {
|
||||
val idField: Field = c.getDeclaredField(variableName)
|
||||
idField.getInt(idField)
|
||||
} catch (e: java.lang.Exception) {
|
||||
e.printStackTrace()
|
||||
R.drawable.laneinfo_0
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user