调整道路属性面板
This commit is contained in:
squallzhjch
2023-05-24 15:57:52 +08:00
parent d89ad95a17
commit 4e997b8632
32 changed files with 390 additions and 106 deletions

View File

@@ -17,7 +17,7 @@ data class SignBean(
val linkId: String,
//坐标
val geometry: String,
//底部文字
//名称
val name: String,
//底部右侧文字
val bottomRightText: String,

View File

@@ -60,7 +60,7 @@ class MainActivity : BaseActivity() {
private val signAdapter by lazy {
SignAdapter { position, signBean ->
rightController.currentDestination?.let {
if (it.id == R.id.EmptyFragment) {
if (it.id == R.id.RightEmptyFragment) {
val bundle = Bundle()
bundle.putParcelable("SignBean", signBean)
rightController.navigate(R.id.EvaluationResultFragment, bundle)
@@ -75,7 +75,7 @@ class MainActivity : BaseActivity() {
private val topSignAdapter by lazy {
TopSignAdapter { position, signBean ->
rightController.currentDestination?.let {
if (it.id == R.id.EmptyFragment) {
if (it.id == R.id.RightEmptyFragment) {
val bundle = Bundle()
bundle.putParcelable("SignBean", signBean)
rightController.navigate(R.id.EvaluationResultFragment, bundle)
@@ -147,9 +147,9 @@ class MainActivity : BaseActivity() {
this,
RecyclerView.HORIZONTAL, false
)
binding.mainActivityTopSignRecyclerview.addItemDecoration(
RecycleViewDivider(this, LinearLayoutManager.HORIZONTAL)
)
// binding.mainActivityTopSignRecyclerview.addItemDecoration(
// RecycleViewDivider(this, LinearLayoutManager.HORIZONTAL)
// )
binding.mainActivityTopSignRecyclerview.adapter = topSignAdapter
@@ -276,7 +276,7 @@ class MainActivity : BaseActivity() {
}
/**
*
*展开或收起右侧面板
*/
fun onSwitchFragment() {
switchFragment = !switchFragment
@@ -288,6 +288,13 @@ class MainActivity : BaseActivity() {
}
}
/**
* 隐藏或显示右侧展开按钮
*/
fun setRightSwitchButton(visibility: Int) {
binding.mainActivityFragmentSwitch.visibility = visibility
}
/**
* 点击录音按钮
*/

View File

@@ -223,7 +223,7 @@ class MainViewModel @Inject constructor(
)
when (element.code) {
2041, 2008 -> topSignList.add(
2041, 2008, 2010 -> topSignList.add(
signBean
)
else -> signList.add(
@@ -386,8 +386,7 @@ class MainViewModel @Inject constructor(
if (layerConfigList != null && !layerConfigList.isEmpty()) {
val omdbVisibleList = layerConfigList.filter { importConfig ->
importConfig.tableGroupName == "OMDB数据"
}.first().tableMap.filter {
entry ->
}.first().tableMap.filter { entry ->
val tableInfo = entry.value
!tableInfo.checked
}.map { entry ->
@@ -426,7 +425,7 @@ class MainViewModel @Inject constructor(
// }
// }
when (navDestination.id) {
R.id.EmptyFragment -> {
R.id.RightEmptyFragment -> {
if (list.size == 1) {
val bundle = Bundle()
bundle.putString("QsId", list[0])

View File

@@ -1,6 +1,7 @@
package com.navinfo.omqs.ui.activity.map
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.navinfo.omqs.R
import com.navinfo.omqs.bean.SignBean
@@ -27,6 +28,36 @@ class TopSignAdapter(private var itemListener: ((Int, SignBean) -> Unit?)? = nul
bd.topSignText.background = holder.viewBinding.root.context.getDrawable(item.iconId)
bd.topSignName.text = item.name
bd.topSignText.text = item.iconText
if (data.size == 1) {
bd.topSignLeftLine.visibility = View.GONE
bd.topSignRightLine.visibility = View.GONE
bd.topSignName.background =
holder.viewBinding.root.context.getDrawable(R.drawable.shape_road_info_top_bg)
bd.topSignText.background =
holder.viewBinding.root.context.getDrawable(R.drawable.shape_road_info_bottom_bg)
} else if (position == 0) {
bd.topSignLeftLine.visibility = View.GONE
bd.topSignRightLine.visibility = View.VISIBLE
bd.topSignName.background =
holder.viewBinding.root.context.getDrawable(R.drawable.shape_road_info_left_top_bg)
bd.topSignText.background =
holder.viewBinding.root.context.getDrawable(R.drawable.shape_road_info_left_bottom_bg)
} else if (position == data.size - 1) {
bd.topSignLeftLine.visibility = View.VISIBLE
bd.topSignRightLine.visibility = View.GONE
bd.topSignName.background =
holder.viewBinding.root.context.getDrawable(R.drawable.shape_road_info_right_top_bg)
bd.topSignText.background =
holder.viewBinding.root.context.getDrawable(R.drawable.shape_road_info_right_bottom_bg)
} else {
bd.topSignLeftLine.visibility = View.VISIBLE
bd.topSignRightLine.visibility = View.VISIBLE
bd.topSignName.background =
holder.viewBinding.root.context.getDrawable(R.drawable.shape_road_info_middle_top_bg)
bd.topSignText.background =
holder.viewBinding.root.context.getDrawable(R.drawable.shape_road_info_middle_bottom_bg)
}
bd.root.setOnClickListener {
itemListener?.invoke(position, item)
}

View File

@@ -5,13 +5,17 @@ import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import androidx.navigation.fragment.findNavController
import com.navinfo.omqs.R
import com.navinfo.omqs.databinding.FragmentEmptyBinding
import com.navinfo.omqs.ui.activity.map.MainActivity
class EmptyFragment :Fragment(){
class EmptyFragment : Fragment() {
private var _binding: FragmentEmptyBinding? = null
private var currentDestinationLabel = ""
private val binding get() = _binding!!
// private val viewModel by lazy { viewModels<EvaluationResultViewModel>().value}
// private val viewModel by lazy { viewModels<EvaluationResultViewModel>().value}
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
@@ -25,6 +29,22 @@ class EmptyFragment :Fragment(){
super.onViewCreated(view, savedInstanceState)
}
override fun onStart() {
super.onStart()
val currentDestination = findNavController().currentDestination
if (currentDestination?.label == "右侧空页面") {
currentDestinationLabel = "右侧空页面"
(activity as MainActivity).setRightSwitchButton(View.GONE)
}
}
override fun onStop() {
super.onStop()
if (currentDestinationLabel == "右侧空页面") {
(activity as MainActivity).setRightSwitchButton(View.VISIBLE)
}
}
override fun onDestroyView() {
super.onDestroyView()
_binding = null

View File

@@ -103,7 +103,7 @@ class EvaluationResultFragment : BaseFragment(), View.OnClickListener {
* 读取元数据
*/
// val id = args.qsId
var id: String = ""
var id = ""
var signBean: SignBean? = null
var filePath: String = ""
arguments?.let {
@@ -235,7 +235,7 @@ class EvaluationResultFragment : BaseFragment(), View.OnClickListener {
val controller = findNavController(R.id.main_activity_middle_fragment)
controller.currentDestination?.let {
//如果之前页面是空fragment直接打开面板
if (it.id == R.id.EmptyFragment) {
if (it.id == R.id.MiddleEmptyFragment) {
findNavController(
R.id.main_activity_middle_fragment
).navigate(R.id.PhenomenonFragment)
@@ -258,7 +258,7 @@ class EvaluationResultFragment : BaseFragment(), View.OnClickListener {
val controller = findNavController(R.id.main_activity_middle_fragment)
controller.currentDestination?.let {
//如果之前页面是空fragment直接打开面板
if (it.id == R.id.EmptyFragment) {
if (it.id == R.id.MiddleEmptyFragment) {
findNavController(
R.id.main_activity_middle_fragment
).navigate(R.id.ProblemLinkFragment)
@@ -282,13 +282,13 @@ class EvaluationResultFragment : BaseFragment(), View.OnClickListener {
}
fun voiceOnTouchStart() {
viewModel!!.startSoundMetter(requireActivity(), binding.evaluationVoice)
viewModel.startSoundMetter(requireActivity(), binding.evaluationVoice)
}
@RequiresApi(Build.VERSION_CODES.Q)
fun voiceOnTouchStop() {
if (Constant.IS_VIDEO_SPEED) {
viewModel!!.stopSoundMeter()
viewModel.stopSoundMeter()
}
}

View File

@@ -190,19 +190,22 @@ class EvaluationResultViewModel @Inject constructor(
list?.let {
if (list.isNotEmpty()) {
//通知页面更新
var classType = list[0]
liveDataLeftTypeList.postValue(it)
var classType = it[0]
if (bean != null) {
val classType2 = roomAppDatabase.getScProblemTypeDao()
.findClassTypeByCode(bean.elementCode)
if (classType2 != null)
if (classType2 != null) {
classType = classType2
}
}
//如果右侧栏没数据,给个默认值
if (liveDataQsRecordBean.value!!.classType.isEmpty()) {
liveDataQsRecordBean.value!!.classType = classType
classTypeTemp = classType
} else {
classType = liveDataQsRecordBean.value!!.classType
}
getProblemList(classType)
}
@@ -313,7 +316,7 @@ class EvaluationResultViewModel @Inject constructor(
fun saveData() {
viewModelScope.launch(Dispatchers.IO) {
val realm = Realm.getDefaultInstance()
liveDataQsRecordBean.value!!.checkTime = DateTimeUtil.getDataTime()
liveDataQsRecordBean.value!!.checkTime = DateTimeUtil.getDataTime()
realm.executeTransaction {
it.copyToRealmOrUpdate(liveDataQsRecordBean.value)
}
@@ -444,7 +447,6 @@ class EvaluationResultViewModel @Inject constructor(
Constant.IS_VIDEO_SPEED = true
//录音动画
//录音动画
if (pop != null) {
pop!!.showAtLocation(v, Gravity.CENTER, 0, 0)
}

View File

@@ -44,10 +44,9 @@ class LeftAdapter(private var itemListener: ((Int, String) -> Unit?)? = null) :
notifyDataSetChanged()
}
fun setRightTitle(title: String) {
fun setSelectTitle(title: String) {
if (title != selectTitle) {
selectTitle = title
notifyDataSetChanged()
}
}
}

View File

@@ -6,9 +6,12 @@ import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.navigation.findNavController
import androidx.navigation.fragment.findNavController
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import androidx.recyclerview.widget.RecyclerView.OnScrollListener
import com.navinfo.omqs.R
import com.navinfo.omqs.databinding.FragmentPhenomenonBinding
import com.navinfo.omqs.ui.fragment.BaseFragment
import com.navinfo.omqs.ui.other.shareViewModels
@@ -19,6 +22,7 @@ class PhenomenonFragment :
BaseFragment() {
private var _binding: FragmentPhenomenonBinding? = null
private val binding get() = _binding!!
/**
* 和[PhenomenonFragment],[ProblemLinkFragment],[EvaluationResultFragment]共用同一个viewModel
*/
@@ -50,6 +54,7 @@ class PhenomenonFragment :
binding.phenomenonLeftRecyclerview.adapter = leftAdapter
//左侧菜单查询结果监听
viewModel.liveDataLeftTypeList.observe(viewLifecycleOwner) {
leftAdapter.setSelectTitle(viewModel.liveDataQsRecordBean.value!!.classType)
leftAdapter.refreshData(it)
}
@@ -63,6 +68,9 @@ class PhenomenonFragment :
*/
val rightAdapter = RightGroupHeaderAdapter { _, bean ->
viewModel.setPhenomenonMiddleBean(bean)
if (activity != null) {
requireActivity().findNavController(R.id.main_activity_middle_fragment).navigateUp()
}
}
binding.phenomenonRightRecyclerview.adapter = rightAdapter
//右侧菜单增加组标题
@@ -75,6 +83,7 @@ class PhenomenonFragment :
}
//右侧菜单查询数据监听
viewModel.liveDataRightTypeList.observe(viewLifecycleOwner) {
rightAdapter.setSelectTitle(viewModel.liveDataQsRecordBean.value!!.classType)
rightAdapter.refreshData(it)
}

View File

@@ -3,12 +3,13 @@ package com.navinfo.omqs.ui.fragment.evaluationresult
import android.view.LayoutInflater
import android.view.ViewGroup
import com.navinfo.omqs.R
import com.navinfo.omqs.databinding.TextItemSelectBinding
import com.navinfo.omqs.databinding.TextItemSelect2Binding
import com.navinfo.omqs.ui.other.BaseRecyclerViewAdapter
import com.navinfo.omqs.ui.other.BaseViewHolder
class RightGroupHeaderAdapter(private var itemListener: ((Int, RightBean) -> Unit?)? = null) :
BaseRecyclerViewAdapter<RightBean>() {
private var selectTitle = ""
private var groupTitleList = mutableListOf<String>()
override fun getItemViewRes(position: Int): Int {
return R.layout.text_item_select2
@@ -16,14 +17,21 @@ class RightGroupHeaderAdapter(private var itemListener: ((Int, RightBean) -> Uni
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): BaseViewHolder {
val viewBinding =
TextItemSelectBinding.inflate(LayoutInflater.from(parent.context), parent, false)
TextItemSelect2Binding.inflate(LayoutInflater.from(parent.context), parent, false)
return BaseViewHolder(viewBinding)
}
override fun onBindViewHolder(holder: BaseViewHolder, position: Int) {
val bd = holder.viewBinding as TextItemSelectBinding
bd.itemId.text = data[position].text
val bd = holder.viewBinding as TextItemSelect2Binding
val title = data[position].text
bd.itemId.text = title
holder.viewBinding.root.isSelected = selectTitle == title
bd.root.setOnClickListener {
if (selectTitle != title) {
selectTitle = title
notifyDataSetChanged()
}
itemListener?.invoke(position, data[position])
}
}
@@ -86,7 +94,6 @@ class RightGroupHeaderAdapter(private var itemListener: ((Int, RightBean) -> Uni
}
override fun refreshData(newData: List<RightBean>) {
super.refreshData(newData)
groupTitleList.clear()
for (item in newData) {
if (groupTitleList.size > 0) {
@@ -97,7 +104,15 @@ class RightGroupHeaderAdapter(private var itemListener: ((Int, RightBean) -> Uni
groupTitleList.add(item.title)
}
}
super.refreshData(newData)
}
/**
* 设置当前选中的哪条数据
*/
fun setSelectTitle(title: String) {
if (title != selectTitle) {
selectTitle = title
}
}
}

View File

@@ -40,7 +40,7 @@ class RightGroupHeaderDecoration(context: Context) : ItemDecoration() {
mTextPaint.textSize = 46f
mTextPaint.color = Color.WHITE
mLinePaint = Paint(Paint.ANTI_ALIAS_FLAG)
mLinePaint.color = Color.GRAY
mLinePaint.color = Color.WHITE
}
/**

View File

@@ -7,38 +7,72 @@ import com.navinfo.omqs.R
class SignUtil {
companion object {
/**
* 获取面板上的文字
*/
fun getSignIconText(data: RenderEntity): String {
return when (data.code) {
//道路功能等级
2002 -> getLinkFunctionClassText(data)
//道路种别
2008 -> getKindText(data)
//道路方向
2010 -> getRoadDirectionText(data)
//车道数
2041 -> getLaneNumText(data)
//常规点限速,条件点限速
4002, 4003 -> getSpeedLimitText(data)
// //道路种别
// 2008 -> getKindCodeIcon(data)
// //道路方向
// 2010 -> getRoadDirection(data)
// //车道数
// 2041 -> getLaneNumIcon(data)
else -> ""
}
}
/**
*获取道路功能等级文字
*/
private fun getLinkFunctionClassText(data: RenderEntity): String {
return "等级${data.properties["functionClass"]}"
}
/**
* 获取道路方向文字
*/
private fun getRoadDirectionText(data: RenderEntity): String {
val direct = data.properties["direct"]
when (direct?.toInt()) {
0 -> return "不应用"
1 -> return "双方向"
2 -> return "顺方向"
3 -> return "逆方向"
}
return ""
}
/**
* 获取车道数展示文字
*/
private fun getLaneNumText(data: RenderEntity): String {
return "${data.properties["laneNum"]}|${data.properties["laneS2e"]}|${data.properties["laneE2s"]}"
}
/**
* 获取要素名称
*/
fun getSignNameText(data: RenderEntity): String {
return when (data.code) {
//可变点限速
4004 -> "可变点限速"
//道路功能等级
2002 -> "功能等级"
//道路种别
2008 -> "种别"
//道路方向
2010 -> "方向"
//车道数
2041 -> "车道数"
//常规点限速
4002 -> "常规点限速"
//常点限速
4003 -> "条件点限速"
//道路种别
2008 -> "道路种别"
//道路方向
2010 -> "道路方向"
//车道数
2041 -> "车道数"
//可变点限速
4004 -> "可变点限速"
else -> ""
}
}
@@ -57,7 +91,6 @@ class SignUtil {
/**
* 条件点限速文字
*/
private fun getConditionLimitText(data: RenderEntity): String {
var stringBuffer = StringBuffer()
try {
@@ -119,6 +152,13 @@ class SignUtil {
return ""
}
/**
* 获取种别名称
*/
private fun getKindText(data: RenderEntity): String {
return data.properties["kind"].toString()
}
/**
* 限速图标
*/
@@ -132,7 +172,23 @@ class SignUtil {
} catch (e: Exception) {
Log.e("jingo", "获取限速面板ICON出错2 $e")
}
return R.drawable.icon_speed_limit
return 0
}
/**
* 条件限速图标
*/
private fun getConditionalSpeedLimitIcon(data: RenderEntity): Int {
try {
//限速标志 0 限速开始 1 限速解除
return when (data.properties["speed_flag"]) {
"1" -> return R.drawable.icon_conditional_speed_limit_off
else -> return R.drawable.icon_conditional_speed_limit
}
} catch (e: Exception) {
Log.e("jingo", "获取限速面板ICON出错2 $e")
}
return 0
}
/**
@@ -141,14 +197,16 @@ class SignUtil {
fun getSignIcon(data: RenderEntity): Int {
return when (data.code) {
//道路种别
2008 -> getKindCodeIcon(data)
//道路方向
2010 -> getRoadDirection(data)
//车道数
2041 -> getLaneNumIcon(data)
//限速
4002, 4003 -> getSpeedLimitIcon(data)
// //道路种别
// 2008 -> getKindCodeIcon(data)
// //道路方向
// 2010 -> getRoadDirection(data)
// //车道数
// 2041 -> getLaneNumIcon(data)
//普通点限速
4002 -> getSpeedLimitIcon(data)
//条件点限速
4003 -> getConditionalSpeedLimitIcon(data)
//可变点限速
4004 -> R.drawable.icon_change_limit
else -> 0
@@ -187,7 +245,7 @@ class SignUtil {
/**
* 获取到路线
*/
fun getLaneNumIcon(data: RenderEntity): Int {
private fun getLaneNumIcon(data: RenderEntity): Int {
try {
val lineNum = data.properties["laneNum"]
return when (lineNum!!.toInt()) {
@@ -211,7 +269,7 @@ class SignUtil {
return R.drawable.icon_road_direction
}
fun getRoadDirection(data: RenderEntity): Int {
private fun getRoadDirection(data: RenderEntity): Int {
try {
val direct = data.properties["direct"]
return when (direct!!.toInt()) {