Merge branch 'master' of https://gitlab.navinfo.com/CollectVehicle/OneMapQS
Conflicts: app/src/main/java/com/navinfo/omqs/ui/activity/map/MainActivity.kt app/src/main/java/com/navinfo/omqs/ui/activity/map/MainViewModel.kt collect-library/src/main/java/com/navinfo/collect/library/map/handler/MarkHandler.kt
This commit is contained in:
@@ -180,7 +180,7 @@ class MainActivity : BaseActivity() {
|
||||
//给xml传递viewModel对象
|
||||
binding.viewModel = viewModel
|
||||
|
||||
binding.mainActivityVoice.setOnTouchListener { v, event ->
|
||||
binding.mainActivityVoice.setOnTouchListener { v, event ->
|
||||
when (event?.action) {
|
||||
MotionEvent.ACTION_DOWN -> {
|
||||
voiceOnTouchStart()//Do Something
|
||||
@@ -210,7 +210,7 @@ class MainActivity : BaseActivity() {
|
||||
}
|
||||
}
|
||||
//捕捉列表变化回调
|
||||
viewModel.liveDataNoteIdList.observe(this) {
|
||||
viewModel.liveDataNoteId.observe(this) {
|
||||
//跳转到质检数据页面
|
||||
//获取右侧fragment容器
|
||||
val naviController = findNavController(R.id.main_activity_right_fragment)
|
||||
@@ -218,16 +218,23 @@ class MainActivity : BaseActivity() {
|
||||
naviController.currentDestination?.let { navDestination ->
|
||||
when (navDestination.id) {
|
||||
R.id.RightEmptyFragment -> {
|
||||
if (it.size == 1) {
|
||||
val bundle = Bundle()
|
||||
bundle.putString("NoteId", it[0])
|
||||
naviController.navigate(R.id.NoteFragment, bundle)
|
||||
}
|
||||
val bundle = Bundle()
|
||||
bundle.putString("NoteId", it)
|
||||
naviController.navigate(R.id.NoteFragment, bundle)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
viewModel.liveDataTaskLink.observe(this) {
|
||||
val bundle = Bundle()
|
||||
bundle.putString("TaskLinkId", it)
|
||||
findNavController(R.id.main_activity_right_fragment).navigate(
|
||||
R.id.TaskLinkFragment,
|
||||
bundle
|
||||
)
|
||||
}
|
||||
|
||||
//捕捉列表变化回调
|
||||
viewModel.liveDataNILocationList.observe(this) {
|
||||
if(viewModel.isSelectTrace()){
|
||||
|
||||
@@ -23,13 +23,10 @@ import androidx.lifecycle.viewModelScope
|
||||
import androidx.navigation.findNavController
|
||||
import com.blankj.utilcode.util.ToastUtils
|
||||
import com.navinfo.collect.library.data.dao.impl.TraceDataBase
|
||||
import com.navinfo.collect.library.data.entity.NiLocation
|
||||
import com.navinfo.collect.library.data.entity.NoteBean
|
||||
import com.navinfo.collect.library.data.entity.QsRecordBean
|
||||
import com.navinfo.collect.library.data.entity.RenderEntity
|
||||
import com.navinfo.collect.library.data.entity.TaskBean
|
||||
import com.navinfo.collect.library.data.entity.*
|
||||
import com.navinfo.collect.library.map.NIMapController
|
||||
import com.navinfo.collect.library.map.handler.OnQsRecordItemClickListener
|
||||
import com.navinfo.collect.library.map.handler.OnTaskLinkItemClickListener
|
||||
import com.navinfo.collect.library.utils.GeometryTools
|
||||
import com.navinfo.collect.library.utils.GeometryToolsKt
|
||||
import com.navinfo.omqs.Constant
|
||||
@@ -76,7 +73,6 @@ class MainViewModel @Inject constructor(
|
||||
private val mapController: NIMapController,
|
||||
private val traceDataBase: TraceDataBase,
|
||||
private val realmOperateHelper: RealmOperateHelper,
|
||||
private val networkService: NetworkService,
|
||||
private val sharedPreferences: SharedPreferences
|
||||
) : ViewModel() {
|
||||
|
||||
@@ -86,7 +82,7 @@ class MainViewModel @Inject constructor(
|
||||
val liveDataQsRecordIdList = MutableLiveData<List<String>>()
|
||||
|
||||
//地图点击捕捉到的标签ID列表
|
||||
val liveDataNoteIdList = MutableLiveData<List<String>>()
|
||||
val liveDataNoteId = MutableLiveData<String>()
|
||||
|
||||
//地图点击捕捉到的轨迹列表
|
||||
val liveDataNILocationList = MutableLiveData<NiLocation>()
|
||||
@@ -100,6 +96,9 @@ class MainViewModel @Inject constructor(
|
||||
//道路名
|
||||
val liveDataRoadName = MutableLiveData<RenderEntity?>()
|
||||
|
||||
//捕捉到新增的link
|
||||
val liveDataTaskLink = MutableLiveData<String>()
|
||||
|
||||
/**
|
||||
* 当前选中的要展示的详细信息的要素
|
||||
*/
|
||||
@@ -174,13 +173,12 @@ class MainViewModel @Inject constructor(
|
||||
liveDataQsRecordIdList.value = list
|
||||
}
|
||||
|
||||
override fun onNoteList(list: MutableList<String>) {
|
||||
liveDataNoteIdList.value = list
|
||||
override fun onNote(id: String) {
|
||||
liveDataNoteId.value = id
|
||||
}
|
||||
|
||||
override fun onNiLocation(index: Int, item: NiLocation) {
|
||||
liveDataNILocationList.value = item
|
||||
currentIndexNiLocation = index
|
||||
}
|
||||
})
|
||||
|
||||
@@ -191,11 +189,11 @@ class MainViewModel @Inject constructor(
|
||||
mapController.onMapClickFlow.collectLatest {
|
||||
// testPoint = it
|
||||
//线选择状态
|
||||
/* if (bSelectRoad) {
|
||||
captureLink(it)
|
||||
} else {
|
||||
captureItem(it)
|
||||
}*/
|
||||
if (bSelectRoad) {
|
||||
captureLink(it)
|
||||
} else {
|
||||
captureItem(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
@@ -257,11 +255,12 @@ class MainViewModel @Inject constructor(
|
||||
//加载轨迹数据
|
||||
val id = sharedPreferences.getInt(Constant.SELECT_TASK_ID, -1)
|
||||
val list: List<NiLocation>? = TraceDataBase.getDatabase(
|
||||
mapController.mMapView.context,
|
||||
Constant.USER_DATA_PATH
|
||||
mapController.mMapView.context, Constant.USER_DATA_PATH
|
||||
).niLocationDao.findToTaskIdAll(id.toString())
|
||||
list!!.forEach {
|
||||
mapController.markerHandle.addNiLocationMarkerItem(it)
|
||||
if (list != null) {
|
||||
for (location in list) {
|
||||
mapController.markerHandle.addNiLocationMarkerItem(location)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -272,6 +271,19 @@ class MainViewModel @Inject constructor(
|
||||
private fun initLocation() {
|
||||
//用于定位点存储到数据库
|
||||
viewModelScope.launch(Dispatchers.Default) {
|
||||
//用于定位点捕捉道路
|
||||
mapController.locationLayerHandler.niLocationFlow.collectLatest { location ->
|
||||
if (!isSelectRoad() && !GeometryTools.isCheckError(
|
||||
location.longitude, location.latitude
|
||||
)
|
||||
) {
|
||||
captureLink(
|
||||
GeoPoint(
|
||||
location.latitude, location.longitude
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
mapController.locationLayerHandler.niLocationFlow.collect { location ->
|
||||
|
||||
//过滤掉无效点
|
||||
@@ -512,12 +524,10 @@ class MainViewModel @Inject constructor(
|
||||
try {
|
||||
if (!mCameraDialog!!.getmShareUtil().connectstate) {
|
||||
mCameraDialog!!.updateCameraResources(
|
||||
1,
|
||||
mCameraDialog!!.getmDeviceNum()
|
||||
1, mCameraDialog!!.getmDeviceNum()
|
||||
)
|
||||
}
|
||||
TakePhotoManager.getInstance()
|
||||
.getCameraVedioClent(mCameraDialog!!.getmDeviceNum())
|
||||
TakePhotoManager.getInstance().getCameraVedioClent(mCameraDialog!!.getmDeviceNum())
|
||||
.StopSearch()
|
||||
} catch (e: Exception) {
|
||||
}
|
||||
|
||||
@@ -39,6 +39,7 @@ import dagger.hilt.android.lifecycle.HiltViewModel
|
||||
import io.realm.Realm
|
||||
import io.realm.RealmList
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.flow.collectLatest
|
||||
import kotlinx.coroutines.launch
|
||||
import org.oscim.core.GeoPoint
|
||||
import java.io.File
|
||||
@@ -109,7 +110,7 @@ class EvaluationResultViewModel @Inject constructor(
|
||||
init {
|
||||
liveDataQsRecordBean.value = QsRecordBean(id = UUID.randomUUID().toString())
|
||||
viewModelScope.launch {
|
||||
mapController.onMapClickFlow.collect {
|
||||
mapController.onMapClickFlow.collectLatest {
|
||||
liveDataQsRecordBean.value!!.geometry = GeometryTools.createGeometry(it).toText()
|
||||
mapController.markerHandle.addMarker(it, markerTitle)
|
||||
viewModelScope.launch {
|
||||
|
||||
@@ -36,6 +36,13 @@ class TaskLinkFragment : BaseFragment(), View.OnClickListener {
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
|
||||
arguments?.let {
|
||||
val id = it.getString("TaskLinkId")
|
||||
if (id != null && id.isNotEmpty()){
|
||||
viewModel.initData(id)
|
||||
}
|
||||
}
|
||||
|
||||
binding.taskLinkAddPoint.setOnClickListener(this)
|
||||
binding.taskLinkKind.setOnClickListener(this)
|
||||
binding.taskLinkFunctionalLevel.setOnClickListener(this)
|
||||
@@ -44,6 +51,8 @@ class TaskLinkFragment : BaseFragment(), View.OnClickListener {
|
||||
binding.taskLinkBarSave.setOnClickListener(this)
|
||||
binding.taskLinkBack.setOnClickListener(this)
|
||||
binding.taskLinkClear.setOnClickListener(this)
|
||||
binding.taskLinkBarDelete.setOnClickListener(this)
|
||||
|
||||
/**
|
||||
* 数据操作结束
|
||||
*/
|
||||
@@ -150,6 +159,9 @@ class TaskLinkFragment : BaseFragment(), View.OnClickListener {
|
||||
binding.taskLinkClear -> {
|
||||
viewModel.clearLink()
|
||||
}
|
||||
binding.taskLinkBarDelete ->{
|
||||
viewModel.deleteData(requireContext())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.navinfo.omqs.ui.fragment.tasklink
|
||||
|
||||
import android.app.Dialog
|
||||
import android.content.Context
|
||||
import android.content.SharedPreferences
|
||||
import android.os.Build
|
||||
import androidx.annotation.RequiresApi
|
||||
@@ -8,15 +10,18 @@ import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import com.navinfo.collect.library.data.entity.HadLinkDvoBean
|
||||
import com.navinfo.collect.library.data.entity.LinkInfoBean
|
||||
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.utils.GeometryTools
|
||||
import com.navinfo.omqs.Constant
|
||||
import com.navinfo.omqs.ui.dialog.FirstDialog
|
||||
import dagger.hilt.android.lifecycle.HiltViewModel
|
||||
import io.realm.Realm
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.flow.collectLatest
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
import org.bson.codecs.UuidCodec
|
||||
import org.bson.internal.UuidHelper
|
||||
import org.oscim.core.GeoPoint
|
||||
@@ -102,6 +107,11 @@ class TaskLinkViewModel @Inject constructor(
|
||||
*/
|
||||
val liveDataTaskBean = MutableLiveData<TaskBean?>()
|
||||
|
||||
/**
|
||||
* 当前正在编辑的线
|
||||
*/
|
||||
private var hadLinkDvoBean: HadLinkDvoBean? = null
|
||||
|
||||
/**
|
||||
* 当前正在选择哪个数据 1:种别 2:功能等级 3:数据等级
|
||||
*/
|
||||
@@ -184,26 +194,50 @@ class TaskLinkViewModel @Inject constructor(
|
||||
liveDataToastMessage.postValue("请选择数据等级!")
|
||||
return@launch
|
||||
}
|
||||
val linkBean = HadLinkDvoBean(
|
||||
// taskId = liveDataTaskBean.value!!.id,
|
||||
linkPid = UUID.randomUUID().toString(),
|
||||
linkStatus = 3,
|
||||
length = mapController.measureLayerHandler.lineLengthLiveData.value!!,
|
||||
geometry = GeometryTools.getLineString(mapController.measureLayerHandler.mPathLayer.points),
|
||||
linkInfo = LinkInfoBean(
|
||||
val task: TaskBean = liveDataTaskBean.value!!
|
||||
if (hadLinkDvoBean != null) {
|
||||
hadLinkDvoBean!!.taskId = liveDataTaskBean.value!!.id
|
||||
hadLinkDvoBean!!.length =
|
||||
mapController.measureLayerHandler.lineLengthLiveData.value!!
|
||||
hadLinkDvoBean!!.geometry =
|
||||
GeometryTools.getLineString(mapController.measureLayerHandler.mPathLayer.points)
|
||||
hadLinkDvoBean!!.linkInfo = LinkInfoBean(
|
||||
kind = liveDataSelectKind.value!!.type,
|
||||
functionLevel = liveDataSelectFunctionLevel.value!!.type,
|
||||
dataLevel = liveDataSelectDataLevel.value!!.type,
|
||||
)
|
||||
)
|
||||
val task: TaskBean = liveDataTaskBean.value!!
|
||||
task.hadLinkDvoList.add(linkBean)
|
||||
for (l in task.hadLinkDvoList) {
|
||||
if (l.linkPid == hadLinkDvoBean!!.linkPid) {
|
||||
task.hadLinkDvoList.remove(l)
|
||||
task.hadLinkDvoList.add(hadLinkDvoBean)
|
||||
break
|
||||
}
|
||||
}
|
||||
} else {
|
||||
hadLinkDvoBean = HadLinkDvoBean(
|
||||
taskId = liveDataTaskBean.value!!.id,
|
||||
linkPid = UUID.randomUUID().toString(),
|
||||
linkStatus = 3,
|
||||
length = mapController.measureLayerHandler.lineLengthLiveData.value!!,
|
||||
geometry = GeometryTools.getLineString(mapController.measureLayerHandler.mPathLayer.points),
|
||||
linkInfo = LinkInfoBean(
|
||||
kind = liveDataSelectKind.value!!.type,
|
||||
functionLevel = liveDataSelectFunctionLevel.value!!.type,
|
||||
dataLevel = liveDataSelectDataLevel.value!!.type,
|
||||
)
|
||||
)
|
||||
task.hadLinkDvoList.add(hadLinkDvoBean)
|
||||
}
|
||||
|
||||
|
||||
val realm = Realm.getDefaultInstance()
|
||||
realm.executeTransaction {
|
||||
it.copyToRealmOrUpdate(hadLinkDvoBean)
|
||||
it.copyToRealmOrUpdate(task)
|
||||
}
|
||||
mapController.lineHandler.addTaskLink(linkBean)
|
||||
sharedPreferences.edit().putString(Constant.SHARED_SYNC_TASK_LINK_ID, linkBean.linkPid)
|
||||
mapController.lineHandler.addTaskLink(hadLinkDvoBean!!)
|
||||
sharedPreferences.edit()
|
||||
.putString(Constant.SHARED_SYNC_TASK_LINK_ID, hadLinkDvoBean!!.linkPid)
|
||||
.apply()
|
||||
liveDataFinish.postValue(true)
|
||||
}
|
||||
@@ -231,4 +265,87 @@ class TaskLinkViewModel @Inject constructor(
|
||||
fun clearLink() {
|
||||
mapController.measureLayerHandler.clear()
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化数据
|
||||
*/
|
||||
fun initData(id: String) {
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
val realm = Realm.getDefaultInstance()
|
||||
val objects =
|
||||
realm.where(HadLinkDvoBean::class.java).equalTo("linkPid", id)
|
||||
.findFirst()
|
||||
objects?.linkInfo?.let {
|
||||
for (kind in kindList) {
|
||||
if (kind.type == it.kind) {
|
||||
liveDataSelectKind.postValue(kind)
|
||||
break
|
||||
}
|
||||
}
|
||||
for (function in functionLevelList) {
|
||||
if (function.type == it.functionLevel) {
|
||||
liveDataSelectFunctionLevel.postValue(function)
|
||||
break
|
||||
}
|
||||
}
|
||||
for (data in dataLevelList) {
|
||||
if (data.type == it.dataLevel) {
|
||||
liveDataSelectDataLevel.postValue(data)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
val task =
|
||||
realm.where(TaskBean::class.java).equalTo("id", objects?.taskId)
|
||||
.findFirst()
|
||||
|
||||
if (task != null) {
|
||||
liveDataTaskBean.postValue(realm.copyFromRealm(task))
|
||||
}
|
||||
hadLinkDvoBean = realm.copyFromRealm(objects)
|
||||
withContext(Dispatchers.Main) {
|
||||
mapController.measureLayerHandler.initPathLine(hadLinkDvoBean?.geometry!!)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除数据
|
||||
*/
|
||||
fun deleteData(context: Context) {
|
||||
if(hadLinkDvoBean == null){
|
||||
liveDataFinish.value = true
|
||||
return
|
||||
}
|
||||
val mDialog = FirstDialog(context)
|
||||
mDialog.setTitle("提示?")
|
||||
mDialog.setMessage("是否删除Mark,请确认!")
|
||||
mDialog.setPositiveButton("确定"
|
||||
) { _, _ ->
|
||||
mDialog.dismiss()
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
val realm = Realm.getDefaultInstance()
|
||||
realm.executeTransaction {
|
||||
val task = it.where(TaskBean::class.java).equalTo("id",hadLinkDvoBean!!.taskId).findFirst()
|
||||
if(task != null) {
|
||||
for (h in task.hadLinkDvoList) {
|
||||
if(h.linkPid == hadLinkDvoBean!!.linkPid)
|
||||
task.hadLinkDvoList.remove(h)
|
||||
break
|
||||
}
|
||||
realm.copyToRealmOrUpdate(task)
|
||||
}
|
||||
|
||||
// val objects = it.where(HadLinkDvoBean::class.java)
|
||||
// .equalTo("linkPid", hadLinkDvoBean!!.linkPid).findFirst()
|
||||
// objects?.deleteFromRealm()
|
||||
}
|
||||
mapController.lineHandler.removeTaskLink(hadLinkDvoBean!!.linkPid)
|
||||
mapController.mMapView.vtmMap.updateMap(true)
|
||||
liveDataFinish.postValue(true)
|
||||
}
|
||||
}
|
||||
mDialog.setNegativeButton("取消", null)
|
||||
mDialog.show()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user