增加车信提前看板显示
调整条件限速,常规限速提前看板,详细看板 调整道路名详细信息
This commit is contained in:
@@ -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 =
|
||||
|
||||
Reference in New Issue
Block a user