增加车信按车道编辑,自动生成问题描述功能

This commit is contained in:
squallzhjch 2023-11-06 16:21:46 +08:00
parent ffba871e3c
commit 763fef952e
21 changed files with 1209 additions and 54 deletions

View File

@ -229,6 +229,7 @@ class ImportPreProcess {
// startEndReference.renderEntityId = renderEntity.id // startEndReference.renderEntityId = renderEntity.id
startEndReference.name = "${renderEntity.name}参考线" startEndReference.name = "${renderEntity.name}参考线"
startEndReference.table = renderEntity.table startEndReference.table = renderEntity.table
startEndReference.code = renderEntity.code
startEndReference.zoomMin = renderEntity.zoomMin startEndReference.zoomMin = renderEntity.zoomMin
startEndReference.zoomMax = renderEntity.zoomMax startEndReference.zoomMax = renderEntity.zoomMax
startEndReference.taskId = renderEntity.taskId startEndReference.taskId = renderEntity.taskId
@ -471,6 +472,7 @@ class ImportPreProcess {
// angleReference.renderEntityId = renderEntity.id // angleReference.renderEntityId = renderEntity.id
angleReference.name = "${renderEntity.name}参考方向" angleReference.name = "${renderEntity.name}参考方向"
angleReference.table = renderEntity.table angleReference.table = renderEntity.table
angleReference.code = renderEntity.code
angleReference.zoomMin = renderEntity.zoomMin angleReference.zoomMin = renderEntity.zoomMin
angleReference.zoomMax = renderEntity.zoomMax angleReference.zoomMax = renderEntity.zoomMax
angleReference.taskId = renderEntity.taskId angleReference.taskId = renderEntity.taskId
@ -624,6 +626,7 @@ class ImportPreProcess {
referenceEntity.name = "${renderEntity.name}参考方向" referenceEntity.name = "${renderEntity.name}参考方向"
referenceEntity.table = renderEntity.table referenceEntity.table = renderEntity.table
referenceEntity.enable = renderEntity.enable referenceEntity.enable = renderEntity.enable
referenceEntity.code = renderEntity.code
referenceEntity.taskId = renderEntity.taskId referenceEntity.taskId = renderEntity.taskId
referenceEntity.zoomMin = renderEntity.zoomMin referenceEntity.zoomMin = renderEntity.zoomMin
referenceEntity.zoomMax = renderEntity.zoomMax referenceEntity.zoomMax = renderEntity.zoomMax
@ -740,6 +743,7 @@ class ImportPreProcess {
// angleReference.renderEntityId = renderEntity.id // angleReference.renderEntityId = renderEntity.id
angleReference.name = "${renderEntity.name}车道中线面" angleReference.name = "${renderEntity.name}车道中线面"
angleReference.table = renderEntity.table angleReference.table = renderEntity.table
angleReference.code = renderEntity.code
Log.e("jingo", "几何转换开始") Log.e("jingo", "几何转换开始")
angleReference.geometry = angleReference.geometry =
GeometryTools.createGeometry(renderEntity.geometry).buffer(0.000010) GeometryTools.createGeometry(renderEntity.geometry).buffer(0.000010)
@ -946,6 +950,7 @@ class ImportPreProcess {
// dynamicSrcReference.renderEntityId = renderEntity.id // dynamicSrcReference.renderEntityId = renderEntity.id
dynamicSrcReference.name = "${renderEntity.name}动态icon" dynamicSrcReference.name = "${renderEntity.name}动态icon"
dynamicSrcReference.table = renderEntity.table dynamicSrcReference.table = renderEntity.table
dynamicSrcReference.code = renderEntity.code
dynamicSrcReference.zoomMin = renderEntity.zoomMin dynamicSrcReference.zoomMin = renderEntity.zoomMin
dynamicSrcReference.zoomMax = renderEntity.zoomMax dynamicSrcReference.zoomMax = renderEntity.zoomMax
dynamicSrcReference.taskId = renderEntity.taskId dynamicSrcReference.taskId = renderEntity.taskId

View File

@ -444,7 +444,7 @@ class RealmOperateHelper() {
} }
if (clazz.name == RenderEntity::class.jvmName) { if (clazz.name == RenderEntity::class.jvmName) {
// 筛选不显示的数据 // 筛选不显示的数据
if (com.navinfo.collect.library.system.Constant.HAD_LAYER_INVISIABLE_ARRAY != null && com.navinfo.collect.library.system.Constant.HAD_LAYER_INVISIABLE_ARRAY.size > 0) { if (com.navinfo.collect.library.system.Constant.HAD_LAYER_INVISIABLE_ARRAY != null && com.navinfo.collect.library.system.Constant.HAD_LAYER_INVISIABLE_ARRAY.isNotEmpty()) {
realmQuery.beginGroup() realmQuery.beginGroup()
for (type in com.navinfo.collect.library.system.Constant.HAD_LAYER_INVISIABLE_ARRAY) { for (type in com.navinfo.collect.library.system.Constant.HAD_LAYER_INVISIABLE_ARRAY) {
realmQuery.notEqualTo("table", type) realmQuery.notEqualTo("table", type)

View File

@ -358,7 +358,7 @@ class MainViewModel @Inject constructor(
if (naviEngineStatus == 1) { if (naviEngineStatus == 1) {
naviEngineNew.let { naviEngineNew.let {
// naviMutex.lock() // naviMutex.lock()
if (testRealm == null) if (testRealm == null)
testRealm = realmOperateHelper.getSelectTaskRealmInstance() testRealm = realmOperateHelper.getSelectTaskRealmInstance()
if (currentTaskBean != null) { if (currentTaskBean != null) {
naviEngineNew.bindingRoute( naviEngineNew.bindingRoute(
@ -570,9 +570,9 @@ class MainViewModel @Inject constructor(
mapController.markerHandle.addNiLocationMarkerItem(location) mapController.markerHandle.addNiLocationMarkerItem(location)
if(Constant.TRACE_COUNT%Constant.TRACE_COUNT_TIME==0){ if (Constant.TRACE_COUNT % Constant.TRACE_COUNT_TIME == 0) {
mapController.markerHandle.addNiLocationMarkerItemSimple(location) mapController.markerHandle.addNiLocationMarkerItemSimple(location)
Log.e("qj","$traceCount===轨迹") Log.e("qj", "$traceCount===轨迹")
} }
} }
} }
@ -638,17 +638,21 @@ class MainViewModel @Inject constructor(
} }
//室内整理工具时不能进行轨迹存储判断轨迹间隔要超过2.5并小于60米 //室内整理工具时不能进行轨迹存储判断轨迹间隔要超过2.5并小于60米
if (Constant.INDOOR_IP.isEmpty() && (disance == 0.0 || (disance > 2.5 && disance < 60))) { if (Constant.INDOOR_IP.isEmpty() && (disance == 0.0 || (disance > 2.5 && disance < 60))) {
traceCount ++ traceCount++
Log.e("jingo", "轨迹插入开始") Log.e("jingo", "轨迹插入开始")
CMLog.writeLogtoFile(MainViewModel::class.java.name,"insertTrace","开始") CMLog.writeLogtoFile(MainViewModel::class.java.name, "insertTrace", "开始")
traceDataBase.niLocationDao.insert(location) traceDataBase.niLocationDao.insert(location)
mapController.markerHandle.addNiLocationMarkerItem(location) mapController.markerHandle.addNiLocationMarkerItem(location)
if(Constant.TRACE_COUNT%Constant.TRACE_COUNT_TIME==0){ if (Constant.TRACE_COUNT % Constant.TRACE_COUNT_TIME == 0) {
mapController.markerHandle.addNiLocationMarkerItemSimple(location) mapController.markerHandle.addNiLocationMarkerItemSimple(location)
} }
mapController.mMapView.vtmMap.updateMap(true) mapController.mMapView.vtmMap.updateMap(true)
lastNiLocaion = location lastNiLocaion = location
CMLog.writeLogtoFile(MainViewModel::class.java.name,"insertTrace",gson.toJson(location)) CMLog.writeLogtoFile(
MainViewModel::class.java.name,
"insertTrace",
gson.toJson(location)
)
Log.e("jingo", "轨迹插入结束") Log.e("jingo", "轨迹插入结束")
} }
} }
@ -871,12 +875,12 @@ class MainViewModel @Inject constructor(
) )
val newLineString = GeometryTools.createLineString(linePoints) val newLineString = GeometryTools.createLineString(linePoints)
linkId?.let { if (linkId.isNotEmpty()) {
val time = System.currentTimeMillis() val time = System.currentTimeMillis()
val elementList = realmOperateHelper.queryLinkByLinkPid(realm, it) val elementList = realmOperateHelper.queryLinkByLinkPid(realm, linkId)
Log.e( Log.e(
"jingo", "jingo",
"捕捉到数据 ${elementList.size}${System.currentTimeMillis() - time}" "捕捉到数据 $linkId ${elementList.size}${System.currentTimeMillis() - time}"
) )
for (element in elementList) { for (element in elementList) {
if (element.code == DataCodeEnum.OMDB_LINK_NAME.code) { if (element.code == DataCodeEnum.OMDB_LINK_NAME.code) {
@ -896,7 +900,7 @@ class MainViewModel @Inject constructor(
) )
Log.e( Log.e(
"jingo", "jingo",
"捕捉到的数据code ${DataCodeEnum.findTableNameByCode(element.code)}" "捕捉到的数据code $linkId ${DataCodeEnum.findTableNameByCode(element.code)}"
) )
when (element.code) { when (element.code) {
DataCodeEnum.OMDB_MULTI_DIGITIZED.code,//上下线分离 DataCodeEnum.OMDB_MULTI_DIGITIZED.code,//上下线分离
@ -974,9 +978,9 @@ class MainViewModel @Inject constructor(
val entityList = realmOperateHelper.getSelectTaskRealmTools( val entityList = realmOperateHelper.getSelectTaskRealmTools(
realm, RenderEntity::class.java, true realm, RenderEntity::class.java, true
).and().equalTo("table", DataCodeEnum.OMDB_RESTRICTION.name).and() ).equalTo("table", DataCodeEnum.OMDB_RESTRICTION.name)
.equalTo( .equalTo(
"properties['linkIn']", it "linkPid", linkId
).findAll() ).findAll()
if (entityList.isNotEmpty()) { if (entityList.isNotEmpty()) {
val outList = entityList.distinct() val outList = entityList.distinct()
@ -988,7 +992,6 @@ class MainViewModel @Inject constructor(
true true
) )
.equalTo("table", DataCodeEnum.OMDB_RD_LINK_KIND.name) .equalTo("table", DataCodeEnum.OMDB_RD_LINK_KIND.name)
.and()
.equalTo( .equalTo(
"linkPid", "linkPid",
outLink outLink
@ -1024,7 +1027,6 @@ class MainViewModel @Inject constructor(
if (!hisRoadName) { if (!hisRoadName) {
liveDataRoadName.postValue(null) liveDataRoadName.postValue(null)
} }
Log.e("jingo", "另一个地方查询数据库")
realm.close() realm.close()
} }
} catch (e: Exception) { } catch (e: Exception) {

View File

@ -25,7 +25,7 @@ interface OnSignAdapterClickListener {
fun onErrorClick(signBean: SignBean) fun onErrorClick(signBean: SignBean)
} }
data class LaneInfoItem(val id: Int, val type: Int) data class LaneInfoItem(var id: Int, var type: Int)
class SignAdapter(private var listener: OnSignAdapterClickListener?) : class SignAdapter(private var listener: OnSignAdapterClickListener?) :
BaseRecyclerViewAdapter<SignBean>() { BaseRecyclerViewAdapter<SignBean>() {

View File

@ -18,6 +18,7 @@ import androidx.navigation.findNavController
import androidx.navigation.fragment.findNavController import androidx.navigation.fragment.findNavController
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import com.navinfo.collect.library.enums.DataCodeEnum
import com.navinfo.omqs.Constant import com.navinfo.omqs.Constant
import com.navinfo.omqs.R import com.navinfo.omqs.R
import com.navinfo.omqs.bean.SignBean import com.navinfo.omqs.bean.SignBean
@ -28,7 +29,9 @@ import com.navinfo.omqs.ui.fragment.BaseFragment
import com.navinfo.omqs.ui.other.shareViewModels import com.navinfo.omqs.ui.other.shareViewModels
import dagger.hilt.android.AndroidEntryPoint import dagger.hilt.android.AndroidEntryPoint
/**
* 评测结果页面
*/
@AndroidEntryPoint @AndroidEntryPoint
class EvaluationResultFragment : BaseFragment(), View.OnClickListener { class EvaluationResultFragment : BaseFragment(), View.OnClickListener {
private lateinit var binding: FragmentEvaluationResultBinding private lateinit var binding: FragmentEvaluationResultBinding
@ -191,6 +194,13 @@ class EvaluationResultFragment : BaseFragment(), View.OnClickListener {
viewModel.initData(id) viewModel.initData(id)
} }
/**
* 车信编辑备注
*/
viewModel.liveDataLanInfoChange.observe(viewLifecycleOwner) {
binding.evaluationDescription.setText(it)
}
viewModel.listDataChatMsgEntityList.observe(viewLifecycleOwner) { viewModel.listDataChatMsgEntityList.observe(viewLifecycleOwner) {
adapter.refreshData(it) adapter.refreshData(it)
} }
@ -205,6 +215,17 @@ class EvaluationResultFragment : BaseFragment(), View.OnClickListener {
} }
viewModel.liveDataQsRecordBean.observe(viewLifecycleOwner) { viewModel.liveDataQsRecordBean.observe(viewLifecycleOwner) {
binding.evaluationId.text = it.id binding.evaluationId.text = it.id
binding.evaluationProblemType.text = it.problemType
if(it.classCode == DataCodeEnum.OMDB_LANEINFO.code) {
when (it.problemType) {
"遗漏", "错误" -> {
activity?.run {
findNavController(R.id.main_activity_middle_fragment).navigate(R.id.LineInfoEditFragment)
}
}
}
}
} }
} }

View File

@ -8,6 +8,7 @@ import android.graphics.Bitmap
import android.graphics.drawable.AnimationDrawable import android.graphics.drawable.AnimationDrawable
import android.graphics.drawable.BitmapDrawable import android.graphics.drawable.BitmapDrawable
import android.os.Build import android.os.Build
import android.provider.ContactsContract.Data
import android.text.TextUtils import android.text.TextUtils
import android.util.Log import android.util.Log
import android.view.Gravity import android.view.Gravity
@ -20,10 +21,8 @@ import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope import androidx.lifecycle.viewModelScope
import com.blankj.utilcode.util.ToastUtils import com.blankj.utilcode.util.ToastUtils
import com.navinfo.collect.library.data.entity.AttachmentBean import com.navinfo.collect.library.data.entity.*
import com.navinfo.collect.library.data.entity.HadLinkDvoBean import com.navinfo.collect.library.enums.DataCodeEnum
import com.navinfo.collect.library.data.entity.QsRecordBean
import com.navinfo.collect.library.data.entity.TaskBean
import com.navinfo.collect.library.map.NIMapController import com.navinfo.collect.library.map.NIMapController
import com.navinfo.collect.library.map.OnGeoPointClickListener import com.navinfo.collect.library.map.OnGeoPointClickListener
import com.navinfo.collect.library.utils.GeometryTools import com.navinfo.collect.library.utils.GeometryTools
@ -34,8 +33,10 @@ import com.navinfo.omqs.bean.ScProblemTypeBean
import com.navinfo.omqs.bean.SignBean import com.navinfo.omqs.bean.SignBean
import com.navinfo.omqs.db.RealmOperateHelper import com.navinfo.omqs.db.RealmOperateHelper
import com.navinfo.omqs.db.RoomAppDatabase import com.navinfo.omqs.db.RoomAppDatabase
import com.navinfo.omqs.ui.activity.map.LaneInfoItem
import com.navinfo.omqs.ui.dialog.FirstDialog import com.navinfo.omqs.ui.dialog.FirstDialog
import com.navinfo.omqs.util.DateTimeUtil import com.navinfo.omqs.util.DateTimeUtil
import com.navinfo.omqs.util.SignUtil
import com.navinfo.omqs.util.SoundMeter import com.navinfo.omqs.util.SoundMeter
import com.navinfo.omqs.util.SpeakMode import com.navinfo.omqs.util.SpeakMode
import dagger.hilt.android.lifecycle.HiltViewModel import dagger.hilt.android.lifecycle.HiltViewModel
@ -58,6 +59,17 @@ class EvaluationResultViewModel @Inject constructor(
private val sharedPreferences: SharedPreferences private val sharedPreferences: SharedPreferences
) : ViewModel(), SharedPreferences.OnSharedPreferenceChangeListener { ) : ViewModel(), SharedPreferences.OnSharedPreferenceChangeListener {
/**
* 关联的数据
*/
var renderEntity: RenderEntity? = null
/**
* 车信列表
*/
var laneInfoList: MutableList<LaneInfoItem>? = null
var liveDataLanInfoChange = MutableLiveData<String>()
private val TAG = "点选marker" private val TAG = "点选marker"
@ -153,6 +165,13 @@ class EvaluationResultViewModel @Inject constructor(
*/ */
fun initNewData(bean: SignBean?, filePath: String) { fun initNewData(bean: SignBean?, filePath: String) {
if (bean != null) {
renderEntity = bean.renderEntity
if (renderEntity!!.code == DataCodeEnum.OMDB_LANEINFO.code) {
laneInfoList = SignUtil.getLineInfoIcons(renderEntity!!)
}
}
//查询元数据 //查询元数据
viewModelScope.launch(Dispatchers.IO) { viewModelScope.launch(Dispatchers.IO) {
/** /**
@ -252,6 +271,13 @@ class EvaluationResultViewModel @Inject constructor(
* //获取问题分类列表 * //获取问题分类列表
*/ */
fun getClassTypeList(bean: SignBean? = null) { fun getClassTypeList(bean: SignBean? = null) {
if (bean != null) {
renderEntity = bean.renderEntity
if (renderEntity!!.code == DataCodeEnum.OMDB_LANEINFO.code) {
laneInfoList = SignUtil.getLineInfoIcons(renderEntity!!)
}
}
viewModelScope.launch(Dispatchers.IO) { viewModelScope.launch(Dispatchers.IO) {
Log.e("jingo", "获取问题分类列表 SSS") Log.e("jingo", "获取问题分类列表 SSS")
val list = roomAppDatabase.getScProblemTypeDao().findClassTypeList() val list = roomAppDatabase.getScProblemTypeDao().findClassTypeList()
@ -307,13 +333,16 @@ class EvaluationResultViewModel @Inject constructor(
) )
) )
} }
val problemLinkB = liveDataQsRecordBean.value!!.problemLink.isEmpty()
val causeB = liveDataQsRecordBean.value!!.cause.isEmpty()
if (liveDataQsRecordBean.value!!.problemLink.isEmpty()) { if (liveDataQsRecordBean.value!!.problemLink.isEmpty()) {
liveDataQsRecordBean.value!!.problemLink = middleList[0] liveDataQsRecordBean.value!!.problemLink = middleList[0]
} }
if (liveDataQsRecordBean.value!!.cause.isEmpty()) { if (liveDataQsRecordBean.value!!.cause.isEmpty()) {
liveDataQsRecordBean.value!!.cause = rightList[0].text liveDataQsRecordBean.value!!.cause = rightList[0].text
} }
liveDataQsRecordBean.postValue(liveDataQsRecordBean.value) if (problemLinkB && causeB)
liveDataQsRecordBean.postValue(liveDataQsRecordBean.value)
// liveDataMiddleTypeList.postValue(middleList) // liveDataMiddleTypeList.postValue(middleList)
liveDataRightTypeList.postValue(rightList) liveDataRightTypeList.postValue(rightList)
} }
@ -342,14 +371,17 @@ class EvaluationResultViewModel @Inject constructor(
) )
) )
} }
if (liveDataQsRecordBean.value!!.problemType.isEmpty()) { val problemTypeB = liveDataQsRecordBean.value!!.problemType.isEmpty()
val phenomenonB = liveDataQsRecordBean.value!!.phenomenon.isEmpty()
if (problemTypeB) {
liveDataQsRecordBean.value!!.problemType = typeTitleList[0] liveDataQsRecordBean.value!!.problemType = typeTitleList[0]
} }
// liveDataMiddleTypeList.postValue(typeTitleList) // liveDataMiddleTypeList.postValue(typeTitleList)
if (liveDataQsRecordBean.value!!.phenomenon.isEmpty()) { if (phenomenonB) {
liveDataQsRecordBean.value!!.phenomenon = phenomenonRightList[0].text liveDataQsRecordBean.value!!.phenomenon = phenomenonRightList[0].text
} }
liveDataQsRecordBean.postValue(liveDataQsRecordBean.value) if (problemTypeB && phenomenonB)
liveDataQsRecordBean.postValue(liveDataQsRecordBean.value)
liveDataRightTypeList.postValue(phenomenonRightList) liveDataRightTypeList.postValue(phenomenonRightList)
} }
} }
@ -389,7 +421,6 @@ class EvaluationResultViewModel @Inject constructor(
*/ */
fun saveData() { fun saveData() {
viewModelScope.launch(Dispatchers.IO) { viewModelScope.launch(Dispatchers.IO) {
val taskBean = liveDataQsRecordBean.value!! val taskBean = liveDataQsRecordBean.value!!
if (liveDataTaskBean.value == null) { if (liveDataTaskBean.value == null) {
@ -510,13 +541,28 @@ class EvaluationResultViewModel @Inject constructor(
} }
} }
liveDataQsRecordBean.value?.attachmentBeanList = it.attachmentBeanList liveDataQsRecordBean.value?.attachmentBeanList = it.attachmentBeanList
liveDataLanInfoChange.value = it.description
// 显示语音数据到界面 // 显示语音数据到界面
getChatMsgEntityList() getChatMsgEntityList()
realm.close()
if (it.elementId == DataCodeEnum.OMDB_LANEINFO.code) {
val realm2 = realmOperateHelper.getSelectTaskRealmInstance()
val r = realm2.where(RenderEntity::class.java)
.equalTo("table", DataCodeEnum.OMDB_LANEINFO.name)
.equalTo("linkPid", it.linkId).findFirst()
if (r != null) {
renderEntity = realm2.copyFromRealm(r)
laneInfoList = SignUtil.getLineInfoIcons(renderEntity!!)
}
realm2.close()
}
} }
} else { } else {
liveDataToastMessage.postValue("数据读取失败") liveDataToastMessage.postValue("数据读取失败")
realm.close()
} }
realm.close()
} }
} }
@ -603,8 +649,9 @@ class EvaluationResultViewModel @Inject constructor(
mSoundMeter!!.setmListener(object : SoundMeter.OnSoundMeterListener { mSoundMeter!!.setmListener(object : SoundMeter.OnSoundMeterListener {
@RequiresApi(Build.VERSION_CODES.Q) @RequiresApi(Build.VERSION_CODES.Q)
override fun onSuccess(filePath: String?) { override fun onSuccess(filePath: String?) {
if (!TextUtils.isEmpty(filePath) && File(filePath).exists()) { filePath?.let {
if (File(filePath) == null || File(filePath).length() < 1600) { val file = File(it)
if (file.exists() && file.length() < 1600) {
ToastUtils.showLong("语音时间太短,无效!") ToastUtils.showLong("语音时间太短,无效!")
mSpeakMode!!.speakText("语音时间太短,无效") mSpeakMode!!.speakText("语音时间太短,无效")
stopSoundMeter() stopSoundMeter()
@ -613,7 +660,6 @@ class EvaluationResultViewModel @Inject constructor(
} }
mSpeakMode!!.speakText("结束录音") mSpeakMode!!.speakText("结束录音")
addChatMsgEntity(filePath!!) addChatMsgEntity(filePath!!)
} }
@ -661,7 +707,7 @@ class EvaluationResultViewModel @Inject constructor(
bitmap.compress(Bitmap.CompressFormat.JPEG, 90, out) bitmap.compress(Bitmap.CompressFormat.JPEG, 90, out)
out.flush() out.flush()
out.close() out.close()
var picList = mutableListOf<String>() val picList = mutableListOf<String>()
if (liveDataPictureList.value == null) { if (liveDataPictureList.value == null) {
picList.add(file.absolutePath) picList.add(file.absolutePath)
} else { } else {
@ -694,4 +740,109 @@ class EvaluationResultViewModel @Inject constructor(
} }
} }
} }
/**
* 增加车信
*/
fun updateLaneInfo(index: Int, id: Int, type: Int) {
laneInfoList?.let {
val laneInfoItem = it[index]
if (laneInfoItem.id != id || laneInfoItem.type != type) {
laneInfoItem.id = id
laneInfoItem.type = type
editLaneInfoProblem()
}
}
}
/**
* 增加车信
*/
fun addLaneInfo(id: Int, type: Int): Int {
laneInfoList?.let {
it.add(LaneInfoItem(id, type))
editLaneInfoProblem()
return it.size
}
return 0
}
/**
* 删除车信
*/
fun backspaceLaneInfo() {
laneInfoList?.let {
if (it.isNotEmpty()) {
it.removeLast()
editLaneInfoProblem()
}
}
}
/**
* 删除车信
*/
fun removeAllLaneInfo() {
laneInfoList?.clear()
}
/**
* 组织车信备注文字
*/
private fun editLaneInfoProblem() {
laneInfoList?.let {
liveDataQsRecordBean.value?.let { bean ->
var strBuffer = StringBuffer()
if (bean.problemType == "遗漏")
strBuffer.append("车信缺失,车道从左到右分别是:")
else if (bean.problemType == "错误")
strBuffer.append("车信错误,车道从左到右分别是:")
for (item in it) {
when (item.id) {
R.drawable.laneinfo_1 -> strBuffer.append("[直(1)")
R.drawable.laneinfo_2 -> strBuffer.append("[左(2)")
R.drawable.laneinfo_3 -> strBuffer.append("[右(3)")
R.drawable.laneinfo_5 -> strBuffer.append("[左斜前(5)")
R.drawable.laneinfo_6 -> strBuffer.append("[右斜前(6)")
R.drawable.laneinfo_4 -> strBuffer.append("[调(4)")
R.drawable.laneinfo_7 -> strBuffer.append("[反向调(7)")
R.drawable.laneinfo_1_2 -> strBuffer.append("[左直(1,2)")
R.drawable.laneinfo_1_5 -> strBuffer.append("[左斜前直(1,5)")
R.drawable.laneinfo_2_5 -> strBuffer.append("[左左斜前(2,5)")
R.drawable.laneinfo_2_6 -> strBuffer.append("[左右斜前(2,6)")
R.drawable.laneinfo_1_3 -> strBuffer.append("[直右(1,3)")
R.drawable.laneinfo_1_6 -> strBuffer.append("[右斜前直(1,6)")
R.drawable.laneinfo_3_5 -> strBuffer.append("[左斜前右(3,5)")
R.drawable.laneinfo_3_6 -> strBuffer.append("[右斜前右(3,6)")
R.drawable.laneinfo_2_3 -> strBuffer.append("[左右(2,3)")
R.drawable.laneinfo_5_6 -> strBuffer.append("[左斜前右斜前(5,6)")
R.drawable.laneinfo_1_4 -> strBuffer.append("[直调(1,4)")
R.drawable.laneinfo_4_5 -> strBuffer.append("[调左斜前(4,5)")
R.drawable.laneinfo_2_4 -> strBuffer.append("[左调(2,4)")
R.drawable.laneinfo_3_4 -> strBuffer.append("[右调(3,4)")
R.drawable.laneinfo_4_6 -> strBuffer.append("[调右斜前(4,6)")
R.drawable.laneinfo_1_7 -> strBuffer.append("[直反向调(1,7)")
R.drawable.laneinfo_1_2_3 -> strBuffer.append("[左直右(1,2,3)")
R.drawable.laneinfo_1_2_4 -> strBuffer.append("[调左直(1,2,4)")
R.drawable.laneinfo_1_2_5 -> strBuffer.append("[左左斜前直(1,2,5)")
R.drawable.laneinfo_1_2_6 -> strBuffer.append("[左直右斜前(1,2,6)")
R.drawable.laneinfo_1_3_4 -> strBuffer.append("[调直右(1,3,4)")
R.drawable.laneinfo_1_3_5 -> strBuffer.append("[左斜前直右(1,3,5)")
R.drawable.laneinfo_1_3_6 -> strBuffer.append("[直右斜前右(1,3,6)")
R.drawable.laneinfo_2_3_4 -> strBuffer.append("[调左右(2,3,4)")
R.drawable.laneinfo_0 -> strBuffer.append("[不允许存在(0)")
}
if (item.type == 1) {
strBuffer.append("(附加)]")
} else if (item.type == 2) {
strBuffer.append("(公交)]")
} else {
strBuffer.append("]")
}
}
liveDataQsRecordBean.value!!.description = strBuffer.toString()
liveDataLanInfoChange.value = strBuffer.toString()
}
}
}
} }

View File

@ -0,0 +1,331 @@
package com.navinfo.omqs.ui.fragment.evaluationresult
import android.graphics.PorterDuff
import android.graphics.PorterDuffColorFilter
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.AdapterView
import android.widget.ImageView
import com.navinfo.omqs.R
import com.navinfo.omqs.databinding.FragmentLineInfoEditBinding
import com.navinfo.omqs.ui.fragment.BaseFragment
import com.navinfo.omqs.ui.other.shareViewModels
class LaneInfoEditFragment : BaseFragment() {
private var _binding: FragmentLineInfoEditBinding? = null
private val binding get() = _binding!!
private val viewModel by shareViewModels<EvaluationResultViewModel>("QsRecode")
/**
* 车道类型
*/
private var laneType = 0
private var selectView: ImageView? = null
private lateinit var laneInfoItemsAdapter: LaneInfoItemsAdapter
private lateinit var laneInfoItemsAdapter2: LaneInfoItems2Adapter
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View {
_binding = FragmentLineInfoEditBinding.inflate(inflater, container, false)
return binding.root
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
initLaneInfo()
initFLowLayout()
binding.laneInfoBackspace.setOnClickListener {
if (binding.laneInfoTopContainer.childCount < 4) {
binding.laneInfoTopContainer.removeAllViews()
} else {
binding.laneInfoTopContainer.removeViewAt(binding.laneInfoTopContainer.childCount - 1)
val view =
binding.laneInfoTopContainer.getChildAt(binding.laneInfoTopContainer.childCount - 1)
binding.laneInfoTopContainer.removeView(view)
if (view == selectView) {
selectView = null
}
}
viewModel.backspaceLaneInfo()
}
binding.laneInfoRadio1.setOnClickListener {
laneType = 0
laneInfoItemsAdapter.setType(laneType)
}
binding.laneInfoRadio2.setOnClickListener {
laneType = 1
laneInfoItemsAdapter.setType(laneType)
}
binding.laneInfoRadio3.setOnClickListener {
laneType = 2
laneInfoItemsAdapter.setType(laneType)
}
}
private fun initFLowLayout() {
val itemList: MutableList<Int> = mutableListOf()
itemList.add(R.drawable.laneinfo_1)
itemList.add(R.drawable.laneinfo_2)
itemList.add(R.drawable.laneinfo_3)
itemList.add(R.drawable.laneinfo_5)
itemList.add(R.drawable.laneinfo_6)
itemList.add(R.drawable.laneinfo_4)
itemList.add(R.drawable.laneinfo_7)
itemList.add(R.drawable.laneinfo_1_2)
itemList.add(R.drawable.laneinfo_1_5)
itemList.add(R.drawable.laneinfo_2_5)
itemList.add(R.drawable.laneinfo_2_6)
itemList.add(R.drawable.laneinfo_1_3)
itemList.add(R.drawable.laneinfo_1_6)
itemList.add(R.drawable.laneinfo_3_5)
itemList.add(R.drawable.laneinfo_3_6)
itemList.add(R.drawable.laneinfo_2_3)
itemList.add(R.drawable.laneinfo_5_6)
itemList.add(R.drawable.laneinfo_1_4)
itemList.add(R.drawable.laneinfo_4_5)
itemList.add(R.drawable.laneinfo_2_4)
itemList.add(R.drawable.laneinfo_3_4)
itemList.add(R.drawable.laneinfo_4_6)
itemList.add(R.drawable.laneinfo_1_7)
itemList.add(R.drawable.laneinfo_1_2_3)
itemList.add(R.drawable.laneinfo_1_2_4)
itemList.add(R.drawable.laneinfo_1_2_5)
itemList.add(R.drawable.laneinfo_1_2_6)
itemList.add(R.drawable.laneinfo_1_3_4)
itemList.add(R.drawable.laneinfo_1_3_5)
itemList.add(R.drawable.laneinfo_1_3_6)
itemList.add(R.drawable.laneinfo_2_3_4)
itemList.add(R.drawable.laneinfo_0)
laneInfoItemsAdapter = LaneInfoItemsAdapter(itemList)
binding.laneInfoGridview.adapter = laneInfoItemsAdapter
binding.laneInfoGridview.onItemClickListener =
AdapterView.OnItemClickListener { parent, view, position, id ->
val resId = laneInfoItemsAdapter.getItem(position) as Int
//如果选中了一个view
if (selectView != null) {
val drawable = requireContext().getDrawable(resId)
val color = when (laneType) {
1 -> requireContext().resources.getColor(R.color.lane_info_1)
2 -> requireContext().resources.getColor(R.color.lane_info_2)
else -> requireContext().resources.getColor(R.color.white)
}
// 创建 PorterDuffColorFilter 对象
val colorFilter = PorterDuffColorFilter(color, PorterDuff.Mode.SRC_IN)
// 将 PorterDuffColorFilter 设置给 Drawable
drawable!!.colorFilter = colorFilter
selectView!!.scaleType = ImageView.ScaleType.FIT_XY
selectView!!.setColorFilter(color, PorterDuff.Mode.SRC_IN)
selectView!!.setImageDrawable(drawable)
viewModel.updateLaneInfo(selectView!!.tag as Int, resId, laneType)
} else {
//如果一条车道都没有,左侧先加一条虚线
if (binding.laneInfoTopContainer.childCount == 0) {
val lineViewS = View(context)
lineViewS.layoutParams = ViewGroup.LayoutParams(24, 110)
lineViewS.background =
requireContext().getDrawable(R.drawable.shape_vertical_dashed_line)
binding.laneInfoTopContainer.addView(lineViewS, lineViewS.layoutParams)
}
val imageView = ImageView(context)
val drawable =
requireContext().getDrawable(laneInfoItemsAdapter.getItem(position) as Int)
val color = when (laneType) {
1 -> requireContext().resources.getColor(R.color.lane_info_1)
2 -> requireContext().resources.getColor(R.color.lane_info_2)
else -> requireContext().resources.getColor(R.color.white)
}
// 创建 PorterDuffColorFilter 对象
val colorFilter = PorterDuffColorFilter(color, PorterDuff.Mode.SRC_IN)
// 将 PorterDuffColorFilter 设置给 Drawable
drawable!!.colorFilter = colorFilter
imageView.setColorFilter(color, PorterDuff.Mode.SRC_IN)
imageView.layoutParams = ViewGroup.LayoutParams(45, 100)
imageView.scaleType = ImageView.ScaleType.FIT_XY
imageView.setImageDrawable(drawable)
imageView.tag = viewModel.addLaneInfo(resId, laneType)
binding.laneInfoTopContainer.addView(imageView)
imageView.setOnClickListener {
selectView = if (selectView == it) {
selectView!!.setBackgroundColor(requireContext().resources.getColor(R.color.gray))
null
} else {
if (selectView != null) {
selectView!!.setBackgroundColor(
requireContext().resources.getColor(
R.color.gray
)
)
}
imageView.setBackgroundColor(requireContext().resources.getColor(R.color.lane_info_0))
it as ImageView
}
}
//右侧加虚线
val lineViewE = View(context)
lineViewE.layoutParams = ViewGroup.LayoutParams(24, 110)
lineViewE.background =
requireContext().getDrawable(R.drawable.shape_vertical_dashed_line)
binding.laneInfoTopContainer.addView(lineViewE)
}
}
val itemList2: MutableList<List<Int>> = mutableListOf()
itemList2.add(listOf(R.drawable.laneinfo_2, R.drawable.laneinfo_1, R.drawable.laneinfo_3))
itemList2.add(listOf(R.drawable.laneinfo_1_2, R.drawable.laneinfo_1, R.drawable.laneinfo_1_3))
itemList2.add(listOf(R.drawable.laneinfo_2, R.drawable.laneinfo_1, R.drawable.laneinfo_1_3))
itemList2.add(listOf(R.drawable.laneinfo_2_4, R.drawable.laneinfo_1, R.drawable.laneinfo_3))
itemList2.add(listOf(R.drawable.laneinfo_1_2, R.drawable.laneinfo_1, R.drawable.laneinfo_3))
itemList2.add(listOf(R.drawable.laneinfo_2_4, R.drawable.laneinfo_1, R.drawable.laneinfo_1_3))
itemList2.add(listOf(R.drawable.laneinfo_2, R.drawable.laneinfo_1, R.drawable.laneinfo_1, R.drawable.laneinfo_3))
itemList2.add(listOf(R.drawable.laneinfo_1_2, R.drawable.laneinfo_1, R.drawable.laneinfo_1, R.drawable.laneinfo_1_3))
itemList2.add(listOf(R.drawable.laneinfo_2, R.drawable.laneinfo_1, R.drawable.laneinfo_1, R.drawable.laneinfo_1_3))
itemList2.add(listOf(R.drawable.laneinfo_2_4, R.drawable.laneinfo_1, R.drawable.laneinfo_1, R.drawable.laneinfo_3))
itemList2.add(listOf(R.drawable.laneinfo_1_2, R.drawable.laneinfo_1, R.drawable.laneinfo_1, R.drawable.laneinfo_3))
itemList2.add(listOf(R.drawable.laneinfo_2_4, R.drawable.laneinfo_1, R.drawable.laneinfo_1, R.drawable.laneinfo_1_3))
laneInfoItemsAdapter2 = LaneInfoItems2Adapter(itemList2)
binding.laneInfoGridview2.adapter = laneInfoItemsAdapter2
binding.laneInfoGridview2.onItemClickListener =
AdapterView.OnItemClickListener { parent, view, position, id ->
val listIds = laneInfoItemsAdapter2.getItem(position) as List<Int>
//如果选中了一个view
if (selectView != null) {
selectView = null
}
binding.laneInfoTopContainer.removeAllViews()
viewModel.removeAllLaneInfo()
for (resId in listIds) {
val lineViewS = View(context)
lineViewS.layoutParams = ViewGroup.LayoutParams(24, 110)
lineViewS.background =
requireContext().getDrawable(R.drawable.shape_vertical_dashed_line)
binding.laneInfoTopContainer.addView(lineViewS, lineViewS.layoutParams)
val imageView = ImageView(context)
val drawable =
requireContext().getDrawable(resId)
val color = when (laneType) {
1 -> requireContext().resources.getColor(R.color.lane_info_1)
2 -> requireContext().resources.getColor(R.color.lane_info_2)
else -> requireContext().resources.getColor(R.color.white)
}
// 创建 PorterDuffColorFilter 对象
val colorFilter = PorterDuffColorFilter(color, PorterDuff.Mode.SRC_IN)
// 将 PorterDuffColorFilter 设置给 Drawable
drawable!!.colorFilter = colorFilter
imageView.setColorFilter(color, PorterDuff.Mode.SRC_IN)
imageView.layoutParams = ViewGroup.LayoutParams(45, 100)
imageView.scaleType = ImageView.ScaleType.FIT_XY
imageView.setImageDrawable(drawable)
imageView.tag = viewModel.addLaneInfo(resId, laneType)
binding.laneInfoTopContainer.addView(imageView)
imageView.setOnClickListener {
selectView = if (selectView == it) {
selectView!!.setBackgroundColor(requireContext().resources.getColor(R.color.gray))
null
} else {
if (selectView != null) {
selectView!!.setBackgroundColor(
requireContext().resources.getColor(
R.color.gray
)
)
}
imageView.setBackgroundColor(requireContext().resources.getColor(R.color.lane_info_0))
it as ImageView
}
}
}
//右侧加虚线
val lineViewE = View(context)
lineViewE.layoutParams = ViewGroup.LayoutParams(24, 110)
lineViewE.background =
requireContext().getDrawable(R.drawable.shape_vertical_dashed_line)
binding.laneInfoTopContainer.addView(lineViewE)
}
}
override fun onDestroyView() {
super.onDestroyView()
_binding = null
}
/**
* 初始化车道信息
*/
private fun initLaneInfo() {
if (viewModel.laneInfoList != null) {
val container = binding.laneInfoTopContainer
container.removeAllViews()
val lineViewS = View(context)
lineViewS.layoutParams = ViewGroup.LayoutParams(24, 110)
lineViewS.background =
requireContext().getDrawable(R.drawable.shape_vertical_dashed_line)
container.addView(lineViewS, lineViewS.layoutParams)
for (i in viewModel.laneInfoList!!.indices) {
val laneInfo = viewModel.laneInfoList!![i]
val imageView = ImageView(context)
val drawable = requireContext().getDrawable(laneInfo.id)
val color = when (laneInfo.type) {
1 -> requireContext().resources.getColor(R.color.lane_info_1)
2 -> requireContext().resources.getColor(R.color.lane_info_2)
else -> requireContext().resources.getColor(R.color.white)
}
// 创建 PorterDuffColorFilter 对象
val colorFilter = PorterDuffColorFilter(color, PorterDuff.Mode.SRC_IN)
// 将 PorterDuffColorFilter 设置给 Drawable
drawable!!.colorFilter = colorFilter
// 将 Drawable 设置给 ImageView
imageView.scaleType = ImageView.ScaleType.FIT_XY
imageView.setColorFilter(color, PorterDuff.Mode.SRC_IN)
imageView.setImageDrawable(drawable)
// 将 ImageView 的颜色设置为红色
imageView.layoutParams = ViewGroup.LayoutParams(45, 100)
container.addView(imageView, imageView.layoutParams)
if (i < viewModel.laneInfoList!!.size - 1) {
val lineView = View(context)
lineView.layoutParams = ViewGroup.LayoutParams(24, 110)
lineView.background =
requireContext().getDrawable(R.drawable.shape_vertical_dashed_line)
container.addView(lineView, lineView.layoutParams)
}
imageView.tag = i
imageView.setOnClickListener {
selectView = if (selectView == it) {
selectView!!.setBackgroundColor(requireContext().resources.getColor(R.color.gray))
null
} else {
if (selectView != null) {
selectView!!.setBackgroundColor(requireContext().resources.getColor(R.color.gray))
}
imageView.setBackgroundColor(requireContext().resources.getColor(R.color.lane_info_0))
it as ImageView
}
}
}
val lineViewE = View(context)
lineViewE.layoutParams = ViewGroup.LayoutParams(24, 110)
lineViewE.background =
requireContext().getDrawable(R.drawable.shape_vertical_dashed_line)
container.addView(lineViewE, lineViewE.layoutParams)
}
}
}

View File

@ -0,0 +1,107 @@
package com.navinfo.omqs.ui.fragment.evaluationresult;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffColorFilter;
import android.graphics.drawable.Drawable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.LinearLayout;
import com.navinfo.omqs.R;
import com.navinfo.omqs.databinding.LaneinfoItemBinding;
import java.util.List;
/**
* 车信图标gridView
*/
public class LaneInfoItems2Adapter extends BaseAdapter {
List<List<Integer>> dataList;
//车道类型 0普通1附加车道2公交车道
private int type = 0;
LaneInfoItems2Adapter(List<List<Integer>> data) {
dataList = data;
}
@Override
public int getCount() {
return dataList.size();
}
@Override
public Object getItem(int position) {
return dataList.get(position);
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder holder;
if (convertView == null) {
LaneinfoItemBinding viewBinding =
LaneinfoItemBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false);
holder = new ViewHolder();
holder.layout = viewBinding.laneinfoItemLayout;
convertView = viewBinding.getRoot();
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
List<Integer> list = dataList.get(position);
holder.layout.removeAllViews();
for (int i : list) {
View lineViewS = new View(parent.getContext());
lineViewS.setLayoutParams(new ViewGroup.LayoutParams(24, 90));
lineViewS.setBackground(parent.getContext().getDrawable(R.drawable.shape_vertical_dashed_line));
holder.layout.addView(lineViewS);
ImageView imageView = new ImageView(parent.getContext());
Drawable drawable = parent.getContext().getDrawable(i);
int color;
switch (type) {
case 1:
color = parent.getContext().getResources().getColor(R.color.lane_info_1);
break;
case 2:
color = parent.getContext().getResources().getColor(R.color.lane_info_2);
break;
default:
color = parent.getContext().getResources().getColor(R.color.white);
break;
}
// 创建 PorterDuffColorFilter 对象
PorterDuffColorFilter colorFilter = new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_IN);
// PorterDuffColorFilter 设置给 Drawable
drawable.setColorFilter(colorFilter);
imageView.setColorFilter(color, PorterDuff.Mode.SRC_IN);
imageView.setBackground(drawable);
imageView.setLayoutParams(new ViewGroup.LayoutParams(36, 80));
holder.layout.addView(imageView);
}
View lineViewS = new View(parent.getContext());
lineViewS.setLayoutParams(new ViewGroup.LayoutParams(24, 90));
lineViewS.setBackground(parent.getContext().getDrawable(R.drawable.shape_vertical_dashed_line));
holder.layout.addView(lineViewS);
return convertView;
}
private class ViewHolder {
LinearLayout layout;
}
public void setType(int type) {
if (type != this.type) {
this.type = type;
notifyDataSetChanged();
}
}
}

View File

@ -0,0 +1,95 @@
package com.navinfo.omqs.ui.fragment.evaluationresult;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffColorFilter;
import android.graphics.drawable.Drawable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.LinearLayout;
import com.navinfo.omqs.R;
import com.navinfo.omqs.databinding.LaneinfoItemBinding;
import com.navinfo.omqs.util.SignUtil;
import java.util.List;
/**
* 车信图标gridView
*/
public class LaneInfoItemsAdapter extends BaseAdapter {
List<Integer> dataList;
//车道类型 0普通1附加车道2公交车道
private int type = 0;
LaneInfoItemsAdapter(List<Integer> data) {
dataList = data;
}
@Override
public int getCount() {
return dataList.size();
}
@Override
public Object getItem(int position) {
return dataList.get(position);
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder holder;
if (convertView == null) {
LaneinfoItemBinding viewBinding =
LaneinfoItemBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false);
holder = new ViewHolder();
holder.layout = viewBinding.laneinfoItemLayout;
convertView = viewBinding.getRoot();
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
ImageView imageView = new ImageView(parent.getContext());
Drawable drawable = parent.getContext().getDrawable(dataList.get(position));
int color;
switch (type) {
case 1:
color = parent.getContext().getResources().getColor(R.color.lane_info_1);
break;
case 2:
color = parent.getContext().getResources().getColor(R.color.lane_info_2);
break;
default:
color = parent.getContext().getResources().getColor(R.color.white);
break;
}
// 创建 PorterDuffColorFilter 对象
PorterDuffColorFilter colorFilter = new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_IN);
// PorterDuffColorFilter 设置给 Drawable
drawable.setColorFilter(colorFilter);
imageView.setBackground(drawable);
holder.layout.removeAllViews();
holder.layout.addView(imageView);
return convertView;
}
private class ViewHolder {
LinearLayout layout;
}
public void setType(int type) {
if (type != this.type) {
this.type = type;
notifyDataSetChanged();
}
}
}

View File

@ -17,6 +17,9 @@ import com.navinfo.omqs.ui.fragment.BaseFragment
import com.navinfo.omqs.ui.other.shareViewModels import com.navinfo.omqs.ui.other.shareViewModels
import dagger.hilt.android.AndroidEntryPoint import dagger.hilt.android.AndroidEntryPoint
/**
* 问题现象页面
*/
@AndroidEntryPoint @AndroidEntryPoint
class PhenomenonFragment : class PhenomenonFragment :
BaseFragment() { BaseFragment() {

View File

@ -12,6 +12,9 @@ import com.navinfo.omqs.databinding.FragmentProblemLinkBinding
import com.navinfo.omqs.ui.fragment.BaseFragment import com.navinfo.omqs.ui.fragment.BaseFragment
import com.navinfo.omqs.ui.other.shareViewModels import com.navinfo.omqs.ui.other.shareViewModels
/**
* 问题环节页面
*/
class ProblemLinkFragment : BaseFragment() { class ProblemLinkFragment : BaseFragment() {
private var _binding: FragmentProblemLinkBinding? = null private var _binding: FragmentProblemLinkBinding? = null
private val binding get() = _binding!! private val binding get() = _binding!!

View File

@ -0,0 +1,306 @@
package com.navinfo.omqs.ui.widget
import android.content.Context
import android.os.Handler
import android.os.Looper
import android.util.AttributeSet
import android.util.SparseArray
import android.util.TypedValue
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.FrameLayout
import android.widget.ImageView
import android.widget.TextView
import androidx.annotation.IntDef
/**
* desc:
* Created by huangxy on 2018/8/15.
*/
class FlowLayout @JvmOverloads constructor(
context: Context?,
attrs: AttributeSet? = null,
defStyleAttr: Int = 0
) : ViewGroup(context, attrs, defStyleAttr) {
private var mLine: Line? = null
//所有的子控件
private var mViews: SparseArray<View?>? = null
/**
* 横向间隔
*/
private var mHorizontalSpacing = DEFAULT_SPACING
/**
* 纵向间隔
*/
private var mVerticalSpacing = DEFAULT_SPACING
/**
* 当前行已用的宽度由子View宽度加上横向间隔
*/
private var mUsedWidth = 0
/**
* 代表每一行的集合
*/
private val mLines: MutableList<Line?> = ArrayList()
//子View的对齐方式
private var isAlignByCenter = 1
/**
* 最大的行数
*/
private val mMaxLinesCount = Int.MAX_VALUE
/**
* 是否需要布局只用于第一次
*/
var mNeedLayout = true
interface AlienState {
@IntDef(value = [RIGHT, LEFT, CENTER])
annotation class Val
companion object {
const val RIGHT = 0
const val LEFT = 1
const val CENTER = 2
}
}
fun setAlignByCenter(@AlienState.Val isAlignByCenter: Int) {
this.isAlignByCenter = isAlignByCenter
requestLayoutInner()
}
private fun requestLayoutInner() {
Handler(Looper.getMainLooper()).post { requestLayout() }
}
fun setAdapter(list: List<*>, res: Int, mItemView: ItemView<*>) {
removeAllViews()
val layoutPadding = dipToPx(context, 8f)
setHorizontalSpacing(layoutPadding)
setVerticalSpacing(layoutPadding)
val size = list.size
for (i in 0 until size) {
val item = list[i]!!
val inflate = LayoutInflater.from(context).inflate(res, null)
mItemView.getCover(item, ViewHolder(inflate), inflate, i)
addView(inflate)
}
}
abstract class ItemView<T> {
abstract fun getCover(item: Any, holder: ViewHolder, inflate: View?, position: Int)
}
inner class ViewHolder(var mConvertView: View) {
init {
mViews = SparseArray()
}
fun <T : View?> getView(viewId: Int): T? {
var view = mViews!![viewId]
if (view == null) {
view = mConvertView.findViewById(viewId)
mViews!!.put(viewId, view)
}
try {
return view as T?
} catch (e: ClassCastException) {
e.printStackTrace()
}
return null
}
fun setImageView(viewId: Int, imageView: ImageView) {
getView<ViewGroup>(viewId)?.addView(imageView)
}
fun setText(viewId: Int, text: String?) {
val view = getView<TextView>(viewId)!!
view.text = text
}
}
fun setHorizontalSpacing(spacing: Int) {
if (mHorizontalSpacing != spacing) {
mHorizontalSpacing = spacing
requestLayoutInner()
}
}
fun setVerticalSpacing(spacing: Int) {
if (mVerticalSpacing != spacing) {
mVerticalSpacing = spacing
requestLayoutInner()
}
}
override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
val sizeWidth = MeasureSpec.getSize(widthMeasureSpec) - paddingRight - paddingLeft
val sizeHeight = MeasureSpec.getSize(heightMeasureSpec) - paddingTop - paddingBottom
val modeWidth = MeasureSpec.getMode(widthMeasureSpec)
val modeHeight = MeasureSpec.getMode(heightMeasureSpec)
restoreLine() // 还原数据,以便重新记录
val count = childCount
for (i in 0 until count) {
val child = getChildAt(i)
if (child.visibility == GONE) {
continue
}
val childWidthMeasureSpec = MeasureSpec.makeMeasureSpec(
sizeWidth,
if (modeWidth == MeasureSpec.EXACTLY) MeasureSpec.AT_MOST else modeWidth
)
val childHeightMeasureSpec = MeasureSpec.makeMeasureSpec(
sizeHeight,
if (modeHeight == MeasureSpec.EXACTLY) MeasureSpec.AT_MOST else modeHeight
)
// 测量child
child.measure(childWidthMeasureSpec, childHeightMeasureSpec)
if (mLine == null) {
mLine = Line()
}
val childWidth = child.measuredWidth
mUsedWidth += childWidth // 增加使用的宽度
if (mUsedWidth <= sizeWidth) { // 使用宽度小于总宽度该child属于这一行。
mLine!!.addView(child) // 添加child
mUsedWidth += mHorizontalSpacing // 加上间隔
if (mUsedWidth >= sizeWidth) { // 加上间隔后如果大于等于总宽度,需要换行
if (!newLine()) {
break
}
}
} else { // 使用宽度大于总宽度。需要换行
if (mLine!!.viewCount == 0) { // 如果这行一个child都没有即使占用长度超过了总长度也要加上去保证每行都有至少有一个child
mLine!!.addView(child) // 添加child
if (!newLine()) { // 换行
break
}
} else { // 如果该行有数据了,就直接换行
if (!newLine()) { // 换行
break
}
// 在新的一行不管是否超过长度先加上去因为这一行一个child都没有所以必须满足每行至少有一个child
mLine!!.addView(child)
mUsedWidth += childWidth + mHorizontalSpacing
}
}
}
if (mLine != null && mLine!!.viewCount > 0 && !mLines.contains(mLine)) {
// 由于前面采用判断长度是否超过最大宽度来决定是否换行,则最后一行可能因为还没达到最大宽度,所以需要验证后加入集合中
mLines.add(mLine)
}
val totalWidth = MeasureSpec.getSize(widthMeasureSpec)
var totalHeight = 0
val linesCount = mLines.size
for (i in 0 until linesCount) { // 加上所有行的高度
totalHeight += mLines[i]!!.mHeight
}
totalHeight += mVerticalSpacing * (linesCount - 1) // 加上所有间隔的高度
totalHeight += paddingTop + paddingBottom // 加上padding
// 设置布局的宽高宽度直接采用父view传递过来的最大宽度而不用考虑子view是否填满宽度因为该布局的特性就是填满一行后再换行
// 高度根据设置的模式来决定采用所有子View的高度之和还是采用父view传递过来的高度
setMeasuredDimension(totalWidth, resolveSize(totalHeight, heightMeasureSpec))
}
private fun restoreLine() {
mLines.clear()
mLine = Line()
mUsedWidth = 0
}
override fun onLayout(changed: Boolean, l: Int, t: Int, r: Int, b: Int) {
if (changed) {
val left = paddingLeft //获取最初的左上点
var top = paddingTop
val count = mLines.size
for (i in 0 until count) {
val line = mLines[i]
line!!.LayoutView(left, top) //摆放每一行中子View的位置
top += line.mHeight + mVerticalSpacing //为下一行的top赋值
}
}
}
/**
* 新增加一行
*/
private fun newLine(): Boolean {
mLines.add(mLine)
if (mLines.size < mMaxLinesCount) {
mLine = Line()
mUsedWidth = 0
return true
}
return false
}
internal inner class Line {
var mWidth = 0 // 该行中所有的子View累加的宽度
var mHeight = 0 // 该行中所有的子View中高度的那个子View的高度
var views: MutableList<View> = ArrayList()
fun addView(view: View) { // 往该行中添加一个
views.add(view)
mWidth += view.measuredWidth
val childHeight = view.measuredHeight
mHeight = if (mHeight < childHeight) childHeight else mHeight //高度等于一行中最高的View
}
val viewCount: Int
get() = views.size
//摆放行中子View的位置
fun LayoutView(l: Int, t: Int) {
var left = l
val count = viewCount
val layoutWidth = measuredWidth - paddingLeft - paddingRight //行的总宽度
//剩余的宽度是除了View和间隙的剩余空间
val surplusWidth = layoutWidth - mWidth - mHorizontalSpacing * (count - 1)
if (surplusWidth >= 0) {
for (i in 0 until count) {
val view = views[i]
val childWidth = view.measuredWidth
val childHeight = view.measuredHeight
//计算出每个View的顶点是由最高的View和该View高度的差值除以2
var topOffset = ((mHeight - childHeight) / 2.0 + 0.5).toInt()
if (topOffset < 0) {
topOffset = 0
}
//布局View
if (i == 0) {
when (isAlignByCenter) {
AlienState.CENTER -> left += surplusWidth / 2
AlienState.RIGHT -> left += surplusWidth
else -> left = 0
}
}
view.layout(
left,
t + topOffset,
left + childWidth,
t + topOffset + childHeight
)
left += childWidth + mVerticalSpacing //为下一个View的left赋值
}
}
}
}
companion object {
const val DEFAULT_SPACING = 20
fun dipToPx(ctx: Context, dip: Float): Int {
return TypedValue.applyDimension(
TypedValue.COMPLEX_UNIT_DIP,
dip,
ctx.resources.displayMetrics
).toInt()
}
}
}

View File

@ -22,6 +22,8 @@ class NaviEngineNew(
DataCodeEnum.OMDB_LINK_NAME.name, DataCodeEnum.OMDB_LINK_NAME.name,
) )
// private latestRoute
// private
private val locationList = mutableListOf<NiLocation>() private val locationList = mutableListOf<NiLocation>()
@ -45,8 +47,6 @@ class NaviEngineNew(
} }
} }
latestRoute?.let { latestRoute?.let {
val res2 = val res2 =

View File

@ -1702,7 +1702,7 @@ class SignUtil {
/** /**
* 获取车信图标 * 获取车信图标
*/ */
fun getLineInfoIcons(renderEntity: RenderEntity): List<LaneInfoItem> { fun getLineInfoIcons(renderEntity: RenderEntity): MutableList<LaneInfoItem> {
val list = mutableListOf<LaneInfoItem>() val list = mutableListOf<LaneInfoItem>()
try { try {
var laneinfoGroup = renderEntity.properties["laneinfoGroup"] var laneinfoGroup = renderEntity.properties["laneinfoGroup"]
@ -1718,7 +1718,7 @@ class SignUtil {
for (i in 0 until itemArray.length()) { for (i in 0 until itemArray.length()) {
val itemObject = itemArray[i] val itemObject = itemArray[i]
val type = typeArray[i] val type = typeArray[i]
var laneInfo = "laneinfo_${itemObject.toString().replace(",", "_")}" val laneInfo = "laneinfo_${itemObject.toString().replace(",", "_")}"
list.add( list.add(
LaneInfoItem( LaneInfoItem(
id = getResId( id = getResId(
@ -1739,7 +1739,7 @@ class SignUtil {
/** /**
* 通过字符串名称获取资源id * 通过字符串名称获取资源id
*/ */
private fun getResId(variableName: String, c: Class<*>): Int { fun getResId(variableName: String, c: Class<*>): Int {
return try { return try {
val idField: Field = c.getDeclaredField(variableName) val idField: Field = c.getDeclaredField(variableName)
idField.getInt(idField) idField.getInt(idField)

View File

@ -4,12 +4,21 @@
android:viewportWidth="24" android:viewportWidth="24"
android:viewportHeight="30"> android:viewportHeight="30">
<path <path
android:pathData="M10.947,29.277l-0.034,-19.755l2.048,0.838l0.032,18.901z" android:pathData="M10.938,29.033l0.027,-20.687l2.037,-0.136l-0.016,20.83z"
android:fillColor="#00C800"/> android:strokeWidth="1"
android:fillColor="#00C800"
android:fillType="nonZero"
android:strokeColor="#00000000"/>
<path <path
android:pathData="M11.226,11.553l10.101,-6.226l-0.601,4.448l2.223,-1.305l0.684,-5.724l-5.484,-2.023l-2.296,1.506l4.597,1.476l-9.535,5.817z" android:pathData="M14.223,4.92C15.325,4.562 17.12,4.485 17.12,4.485L20.138,4.497L17.274,1.022L19.861,0.96L23.471,5.48L19.867,10.106L17.113,10.037L20.251,6.347L16.921,6.331C16.921,6.331 15.296,6.324 14.165,7.119C13.035,7.913 12.992,9.509 12.986,9.896C12.981,10.284 10.68,8.767 11.057,8.081C11.711,6.524 12.646,5.428 14.223,4.92Z"
android:fillColor="#00C800"/> android:strokeWidth="1"
android:fillColor="#00C800"
android:fillType="nonZero"
android:strokeColor="#00000000"/>
<path <path
android:pathData="M12.769,18.262C12.502,12.908 3.819,12.899 3.917,18.379L3.943,26.328L0.432,23.234L0.367,25.297L5.004,29.196L9.432,25.322L9.439,23.058L5.942,26.233L5.96,18.779C6.043,15.185 10.721,15.318 10.908,18.685L12.769,18.262Z" android:pathData="M12.931,18.041C12.664,12.687 3.981,12.678 4.079,18.158L4.105,26.107L0.594,23.013L0.529,25.076L5.166,28.975L9.594,25.101L9.6,22.837L6.104,26.012L6.122,18.558C6.205,14.964 10.883,15.097 11.07,18.464L12.931,18.041Z"
android:fillColor="#00C800"/> android:strokeWidth="1"
android:fillColor="#00C800"
android:fillType="nonZero"
android:strokeColor="#00000000"/>
</vector> </vector>

View File

@ -51,9 +51,9 @@
android:layout_marginRight="5dp" android:layout_marginRight="5dp"
android:background="@color/transparent" android:background="@color/transparent"
android:src="@drawable/icon_delete" android:src="@drawable/icon_delete"
app:layout_constraintBottom_toBottomOf="@id/evaluation_bar_save"
app:layout_constraintRight_toLeftOf="@id/evaluation_bar_save" app:layout_constraintRight_toLeftOf="@id/evaluation_bar_save"
app:layout_constraintTop_toTopOf="@id/evaluation_bar_save" app:layout_constraintTop_toTopOf="@id/evaluation_bar_save" />
app:layout_constraintBottom_toBottomOf="@id/evaluation_bar_save" />
<ImageButton <ImageButton
@ -62,9 +62,9 @@
android:layout_height="40dp" android:layout_height="40dp"
android:background="@color/transparent" android:background="@color/transparent"
android:src="@drawable/measuring_tool_distance" android:src="@drawable/measuring_tool_distance"
app:layout_constraintBottom_toBottomOf="@id/evaluation_bar_save"
app:layout_constraintRight_toLeftOf="@id/evaluation_bar_delete" app:layout_constraintRight_toLeftOf="@id/evaluation_bar_delete"
app:layout_constraintTop_toTopOf="@id/evaluation_bar_save" app:layout_constraintTop_toTopOf="@id/evaluation_bar_save" />
app:layout_constraintBottom_toBottomOf="@id/evaluation_bar_save"/>
<androidx.core.widget.NestedScrollView <androidx.core.widget.NestedScrollView
android:layout_width="0dp" android:layout_width="0dp"
@ -84,6 +84,7 @@
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_marginBottom="7dp" android:layout_marginBottom="7dp"
android:orientation="vertical"> android:orientation="vertical">
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
@ -97,8 +98,7 @@
<TextView <TextView
android:id="@+id/evaluation_id" android:id="@+id/evaluation_id"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content" />
/>
</LinearLayout> </LinearLayout>
@ -152,7 +152,7 @@
android:id="@+id/evaluation_problem_type" android:id="@+id/evaluation_problem_type"
style="@style/evaluation_fragment_text_style" style="@style/evaluation_fragment_text_style"
android:onClick="@{fragment::onClick}" android:onClick="@{fragment::onClick}"
android:text="@{viewModel.liveDataQsRecordBean.problemType}" /> android:text="" />
</LinearLayout> </LinearLayout>
@ -223,6 +223,7 @@
android:text="问题描述" /> android:text="问题描述" />
<com.navinfo.omqs.ui.widget.MyEditeText <com.navinfo.omqs.ui.widget.MyEditeText
android:id="@+id/evaluation_description"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="@drawable/shape_rect_white_2dp_bg" android:background="@drawable/shape_rect_white_2dp_bg"
@ -235,7 +236,6 @@
android:paddingLeft="12dp" android:paddingLeft="12dp"
android:paddingTop="2dp" android:paddingTop="2dp"
android:paddingBottom="2dp" android:paddingBottom="2dp"
android:text="@={viewModel.liveDataQsRecordBean.description}"
android:textSize="12sp" /> android:textSize="12sp" />
</LinearLayout> </LinearLayout>

View File

@ -0,0 +1,107 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="55dp"
tools:context=".ui.fragment.evaluationresult.LaneInfoEditFragment">
<LinearLayout
android:layout_width="@dimen/fragment_phenomenon_width"
android:layout_height="match_parent"
android:layout_gravity="right"
android:background="@drawable/shape_middle_fragment_bg"
android:clickable="true"
android:orientation="vertical">
<HorizontalScrollView
android:id="@+id/lane_info_top_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="10dp"
android:requiresFadingEdge="horizontal"
android:layout_gravity="center_horizontal"
android:gravity="center_horizontal"
>
<LinearLayout
android:id="@+id/lane_info_top_container"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@color/gray"
android:orientation="horizontal"
android:padding="5dp" />
</HorizontalScrollView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal">
<RadioGroup
android:id="@+id/lane_info_radiogroup"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:orientation="horizontal">
<RadioButton
android:id="@+id/lane_info_radio_1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:text="普通车道"
android:textColor="@color/lane_info_0" />
<RadioButton
android:id="@+id/lane_info_radio_2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="false"
android:text="附加车道"
android:textColor="@color/lane_info_1" />
<RadioButton
android:id="@+id/lane_info_radio_3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="false"
android:text="公交车道"
android:textColor="@color/lane_info_2" />
</RadioGroup>
<ImageButton
android:id="@+id/lane_info_backspace"
android:layout_width="60dp"
android:layout_height="wrap_content"
android:src="@drawable/icon_back_n" />
</LinearLayout>
<GridView
android:id="@+id/lane_info_gridview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:horizontalSpacing="2dp"
android:numColumns="8"
android:paddingLeft="20dp"
android:paddingRight="20dp"
android:scrollbars="none"
android:verticalSpacing="2dp" />
<GridView
android:id="@+id/lane_info_gridview2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:horizontalSpacing="2dp"
android:numColumns="2"
android:layout_marginTop="8dp"
android:paddingLeft="20dp"
android:paddingRight="20dp"
android:scrollbars="none"
android:verticalSpacing="2dp" />
</LinearLayout>
</FrameLayout>

View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/laneinfo_item_layout"
android:padding="2dp"
android:orientation="horizontal"
android:background="@color/gray"
android:gravity="center"
android:layout_width="match_parent"
android:layout_height="60dp">
</LinearLayout>

View File

@ -30,5 +30,9 @@
android:name="com.navinfo.omqs.ui.fragment.tasklink.TaskLinkMiddleFragment" android:name="com.navinfo.omqs.ui.fragment.tasklink.TaskLinkMiddleFragment"
android:label="新增评测Link属性选择页面" android:label="新增评测Link属性选择页面"
tools:layout="@layout/fragment_task_link_middle"></fragment> tools:layout="@layout/fragment_task_link_middle"></fragment>
<fragment
android:id="@+id/LineInfoEditFragment"
android:name="com.navinfo.omqs.ui.fragment.evaluationresult.LaneInfoEditFragment"
android:label="车信问题编辑页面"
tools:layout="@layout/fragment_line_info_edit"></fragment>
</navigation> </navigation>

View File

@ -29,7 +29,7 @@ open class QsRecordBean @JvmOverloads constructor(
/** /**
* linkPid 绑定的道路ID * linkPid 绑定的道路ID
*/ */
var linkId: String = "84207223282277331", var linkId: String = "",
/** /**
*问题分类 *问题分类
*/ */

View File

@ -132,7 +132,7 @@ public class OMDBTileDataSource implements ITileDataSource {
List<RenderEntity> listResult = realmQuery.findAll(); List<RenderEntity> listResult = realmQuery.findAll();
long newTime = System.currentTimeMillis() - time; long newTime = System.currentTimeMillis() - time;
Log.e("jingo", "当前OMDBTileDataSource " + Thread.currentThread().hashCode() + " 当前realm " + realm.hashCode() + " 查询耗时" + newTime + " 条数" + listResult.size()); // Log.e("jingo", "当前OMDBTileDataSource " + Thread.currentThread().hashCode() + " 当前realm " + realm.hashCode() + " 查询耗时" + newTime + " 条数" + listResult.size());
// 数据记录的tile号是以正外接tile号列表此处过滤并未与当前tile相交的数据 // 数据记录的tile号是以正外接tile号列表此处过滤并未与当前tile相交的数据
if (!listResult.isEmpty()) { if (!listResult.isEmpty()) {
Polygon tilePolygon = GeometryTools.getTilePolygon(tile); Polygon tilePolygon = GeometryTools.getTilePolygon(tile);