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 app/src/main/java/com/navinfo/omqs/ui/fragment/evaluationresult/EvaluationResultViewModel.kt
This commit is contained in:
@@ -10,6 +10,7 @@ import androidx.annotation.RequiresApi
|
||||
import androidx.core.view.WindowCompat
|
||||
import androidx.databinding.DataBindingUtil
|
||||
import androidx.navigation.findNavController
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import com.blankj.utilcode.util.ToastUtils
|
||||
import com.navinfo.collect.library.map.NIMapController
|
||||
import com.navinfo.collect.library.map.handler.NiLocationListener
|
||||
@@ -37,6 +38,7 @@ class MainActivity : BaseActivity() {
|
||||
@Inject
|
||||
lateinit var offlineMapDownloadManager: OfflineMapDownloadManager
|
||||
|
||||
private val signAdapter by lazy { SignAdapter() }
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
WindowCompat.setDecorFitsSystemWindows(window, false)
|
||||
@@ -48,7 +50,7 @@ class MainActivity : BaseActivity() {
|
||||
binding.mainActivityMap,
|
||||
null,
|
||||
Constant.MAP_PATH,
|
||||
Constant.USER_DATA_PATH+"/trace.sqlite"
|
||||
Constant.USER_DATA_PATH + "/trace.sqlite"
|
||||
)
|
||||
//关联生命周期
|
||||
binding.lifecycleOwner = this
|
||||
@@ -81,7 +83,11 @@ class MainActivity : BaseActivity() {
|
||||
//处理页面跳转
|
||||
viewModel.navigation(this, it)
|
||||
}
|
||||
|
||||
binding.mainActivitySignRecyclerview.layoutManager = LinearLayoutManager(this)
|
||||
binding.mainActivitySignRecyclerview.adapter = signAdapter
|
||||
viewModel.liveDataSignList.observe(this) {
|
||||
signAdapter.refreshData(it)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onStart() {
|
||||
@@ -89,15 +95,10 @@ class MainActivity : BaseActivity() {
|
||||
|
||||
//开启定位
|
||||
mapController.locationLayerHandler.startLocation()
|
||||
|
||||
//启动轨迹存储
|
||||
mapController.locationLayerHandler.setNiLocationListener(NiLocationListener {
|
||||
//ToastUtils.showLong("定位${it.longitude}")
|
||||
binding!!.viewModel!!.addSaveTrace(it)
|
||||
})
|
||||
binding!!.viewModel!!.startSaveTraceThread(this)
|
||||
//显示轨迹图层
|
||||
// mapController.layerManagerHandler.showNiLocationLayer(Constant.DATA_PATH+ SystemConstant.USER_ID+"/trace.sqlite")
|
||||
mapController.layerManagerHandler.showNiLocationLayer()
|
||||
// viewModel.startSaveTraceThread(this)
|
||||
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
@@ -128,7 +129,7 @@ class MainActivity : BaseActivity() {
|
||||
*/
|
||||
fun openCamera() {
|
||||
//显示轨迹图层
|
||||
binding!!.viewModel!!.onClickCameraButton(this)
|
||||
viewModel.onClickCameraButton(this)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -6,6 +6,7 @@ import android.content.DialogInterface
|
||||
import android.graphics.drawable.AnimationDrawable
|
||||
import android.graphics.drawable.BitmapDrawable
|
||||
import android.os.Build
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.text.TextUtils
|
||||
import android.util.Log
|
||||
@@ -15,25 +16,33 @@ import android.view.ViewGroup
|
||||
import android.widget.ImageView
|
||||
import android.widget.PopupWindow
|
||||
import androidx.annotation.RequiresApi
|
||||
import androidx.annotation.RequiresApi
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.ViewModel
|
||||
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.RenderEntity
|
||||
import com.navinfo.collect.library.map.NIMapController
|
||||
import com.navinfo.collect.library.map.handler.NiLocationListener
|
||||
import com.navinfo.collect.library.map.handler.OnQsRecordItemClickListener
|
||||
import com.navinfo.collect.library.utils.GeometryTools
|
||||
import com.navinfo.collect.library.utils.GeometryToolsKt
|
||||
import com.navinfo.omqs.Constant
|
||||
import com.navinfo.omqs.R
|
||||
import com.navinfo.omqs.db.RealmOperateHelper
|
||||
import com.navinfo.omqs.ui.dialog.CommonDialog
|
||||
import com.navinfo.omqs.ui.manager.TakePhotoManager
|
||||
import com.navinfo.omqs.util.DateTimeUtil
|
||||
import com.navinfo.omqs.util.SoundMeter
|
||||
import com.navinfo.omqs.util.SpeakMode
|
||||
import dagger.hilt.android.lifecycle.HiltViewModel
|
||||
import dagger.hilt.android.qualifiers.ActivityContext
|
||||
import dagger.hilt.android.qualifiers.ApplicationContext
|
||||
import io.realm.RealmSet
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import org.oscim.core.GeoPoint
|
||||
import org.videolan.libvlc.LibVlcUtil
|
||||
import java.io.File
|
||||
@@ -43,14 +52,25 @@ import javax.inject.Inject
|
||||
/**
|
||||
* 创建Activity全局viewmode
|
||||
*/
|
||||
|
||||
@HiltViewModel
|
||||
class MainViewModel @Inject constructor(
|
||||
private val mapController: NIMapController
|
||||
private val mapController: NIMapController,
|
||||
private val traceDataBase: TraceDataBase,
|
||||
private val realmOperateHelper: RealmOperateHelper
|
||||
) : ViewModel() {
|
||||
|
||||
val liveDataQsRecordIdList = MutableLiveData<List<String>>()
|
||||
private var mCameraDialog: CommonDialog? = null
|
||||
|
||||
//地图点击捕捉到的质检数据ID列表
|
||||
val liveDataQsRecordIdList = MutableLiveData<List<String>>()
|
||||
|
||||
//看板数据
|
||||
val liveDataSignList = MutableLiveData<List<SignBean>>()
|
||||
|
||||
|
||||
// private var niLocationList: MutableList<NiLocation> = ArrayList<NiLocation>()
|
||||
var testPoint = GeoPoint(0, 0)
|
||||
//语音窗体
|
||||
private var pop: PopupWindow? = null
|
||||
|
||||
@@ -69,6 +89,93 @@ class MainViewModel @Inject constructor(
|
||||
liveDataQsRecordIdList.value = list
|
||||
}
|
||||
})
|
||||
initLocation()
|
||||
viewModelScope.launch {
|
||||
mapController.onMapClickFlow.collect {
|
||||
testPoint = it
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private fun initLocation() {
|
||||
// mapController.locationLayerHandler.setNiLocationListener(NiLocationListener {
|
||||
// addSaveTrace(it)
|
||||
//
|
||||
// })
|
||||
//用于定位点存储到数据库
|
||||
viewModelScope.launch(Dispatchers.Default) {
|
||||
mapController.locationLayerHandler.niLocationFlow.collect { location ->
|
||||
location.longitude = testPoint.longitude
|
||||
location.latitude = testPoint.latitude
|
||||
val geometry = GeometryTools.createGeometry(
|
||||
GeoPoint(
|
||||
location.latitude,
|
||||
location.longitude
|
||||
)
|
||||
)
|
||||
val tileX = RealmSet<Int>()
|
||||
GeometryToolsKt.getTileXByGeometry(geometry.toString(), tileX)
|
||||
val tileY = RealmSet<Int>()
|
||||
GeometryToolsKt.getTileYByGeometry(geometry.toString(), tileY)
|
||||
|
||||
//遍历存储tile对应的x与y的值
|
||||
tileX.forEach { x ->
|
||||
tileY.forEach { y ->
|
||||
location.tilex = x
|
||||
location.tiley = y
|
||||
}
|
||||
}
|
||||
Log.e("jingo", "定位点插入 ${Thread.currentThread().name}")
|
||||
traceDataBase.niLocationDao.insert(location)
|
||||
}
|
||||
}
|
||||
//用于定位点捕捉道路
|
||||
viewModelScope.launch(Dispatchers.Default) {
|
||||
mapController.locationLayerHandler.niLocationFlow.collect { location ->
|
||||
Log.e("jingo", "定位点绑定道路 ${Thread.currentThread().name}")
|
||||
location.longitude = testPoint.longitude
|
||||
location.latitude = testPoint.latitude
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
val linkList = realmOperateHelper.queryLink(
|
||||
point = GeometryTools.createPoint(
|
||||
location.longitude,
|
||||
location.latitude
|
||||
),
|
||||
)
|
||||
//看板数据
|
||||
val signList = mutableListOf<SignBean>()
|
||||
if (linkList.isNotEmpty()) {
|
||||
val link = linkList[0]
|
||||
val linkId = link.properties[RenderEntity.Companion.LinkTable.linkPid]
|
||||
mapController.lineHandler.showLine(link.geometry)
|
||||
linkId?.let {
|
||||
var elementList = realmOperateHelper.queryLinkByLinkPid(it)
|
||||
for (element in elementList) {
|
||||
val distance = GeometryTools.distanceToDouble(
|
||||
GeoPoint(
|
||||
location.latitude, location.longitude,
|
||||
),
|
||||
GeometryTools.createGeoPoint(element.geometry)
|
||||
)
|
||||
signList.add(
|
||||
SignBean(
|
||||
iconId = R.drawable.icon_speed_limit,
|
||||
iconText = element.name,
|
||||
distance = distance.toInt(),
|
||||
)
|
||||
)
|
||||
}
|
||||
liveDataSignList.postValue(signList)
|
||||
Log.e("jingo", "自动捕捉数据 共${elementList.size}条")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//显示轨迹图层
|
||||
mapController.layerManagerHandler.showNiLocationLayer()
|
||||
|
||||
}
|
||||
|
||||
@@ -121,144 +228,61 @@ class MainViewModel @Inject constructor(
|
||||
})
|
||||
}
|
||||
|
||||
fun startSaveTraceThread(context: Context) {
|
||||
Thread(Runnable {
|
||||
try {
|
||||
while (true) {
|
||||
if (niLocationList != null && niLocationList.size > 0) {
|
||||
|
||||
var niLocation = niLocationList[0]
|
||||
val geometry = GeometryTools.createGeometry(
|
||||
GeoPoint(
|
||||
niLocation.latitude,
|
||||
niLocation.longitude
|
||||
)
|
||||
)
|
||||
val tileX = RealmSet<Int>()
|
||||
GeometryToolsKt.getTileXByGeometry(geometry.toString(), tileX)
|
||||
val tileY = RealmSet<Int>()
|
||||
GeometryToolsKt.getTileYByGeometry(geometry.toString(), tileY)
|
||||
|
||||
//遍历存储tile对应的x与y的值
|
||||
tileX.forEach { x ->
|
||||
tileY.forEach { y ->
|
||||
niLocation.tilex = x
|
||||
niLocation.tiley = y
|
||||
}
|
||||
}
|
||||
|
||||
TraceDataBase.getDatabase(
|
||||
context,
|
||||
Constant.USER_DATA_PATH + "/trace.sqlite"
|
||||
).niLocationDao.insert(niLocation)
|
||||
val list = TraceDataBase.getDatabase(
|
||||
context,
|
||||
Constant.USER_DATA_PATH + "/trace.sqlite"
|
||||
).niLocationDao.findAll()
|
||||
niLocationList.remove(niLocation)
|
||||
Log.e("qj", "saveTrace==${niLocationList.size}===${list.size}")
|
||||
|
||||
}
|
||||
Thread.sleep(30)
|
||||
}
|
||||
} catch (e: InterruptedException) {
|
||||
e.printStackTrace()
|
||||
Log.e("qj", "异常==${e.message}")
|
||||
}
|
||||
}).start()
|
||||
}
|
||||
|
||||
//增加轨迹存储
|
||||
fun addSaveTrace(niLocation: NiLocation) {
|
||||
if (niLocation != null && niLocationList != null) {
|
||||
niLocationList.add(niLocation)
|
||||
}
|
||||
}
|
||||
|
||||
fun startSoundMetter(context: Context, niLocation: NiLocation?, v: View) {
|
||||
if (niLocation == null) {
|
||||
ToastUtils.showLong("未获取到GPS信息,请检查GPS是否正常!")
|
||||
//停止录音动画
|
||||
if (pop != null && pop!!.isShowing())
|
||||
pop!!.dismiss();
|
||||
return;
|
||||
}
|
||||
|
||||
if(mSpeakMode==null){
|
||||
mSpeakMode = SpeakMode(context as Activity?)
|
||||
}
|
||||
|
||||
//语音识别动画
|
||||
if (pop == null) {
|
||||
pop = PopupWindow()
|
||||
pop!!.width = ViewGroup.LayoutParams.MATCH_PARENT
|
||||
pop!!.height = ViewGroup.LayoutParams.WRAP_CONTENT
|
||||
pop!!.setBackgroundDrawable(BitmapDrawable())
|
||||
val view = View.inflate(context, R.layout.cv_card_voice_rcd_hint_window, null)
|
||||
pop!!.contentView = view
|
||||
volume = view.findViewById(R.id.volume)
|
||||
}
|
||||
|
||||
pop!!.update()
|
||||
|
||||
Constant.IS_VIDEO_SPEED = true
|
||||
//录音动画
|
||||
//录音动画
|
||||
if (pop != null) {
|
||||
pop!!.showAtLocation(v, Gravity.CENTER, 0, 0)
|
||||
}
|
||||
volume!!.setBackgroundResource(R.drawable.pop_voice_img)
|
||||
val animation = volume!!.background as AnimationDrawable
|
||||
animation.start()
|
||||
|
||||
val name: String = DateTimeUtil.getTimeSSS().toString() + ".m4a"
|
||||
if (mSoundMeter == null) {
|
||||
mSoundMeter = SoundMeter()
|
||||
}
|
||||
mSoundMeter!!.setmListener(object : SoundMeter.OnSoundMeterListener {
|
||||
@RequiresApi(Build.VERSION_CODES.Q)
|
||||
override fun onSuccess(filePath: String?) {
|
||||
if (!TextUtils.isEmpty(filePath) && File(filePath).exists()) {
|
||||
if (File(filePath) == null || File(filePath).length() < 1600) {
|
||||
ToastUtils.showLong("语音时间太短,无效!")
|
||||
mSpeakMode!!.speakText("语音时间太短,无效")
|
||||
stopSoundMeter()
|
||||
return
|
||||
}
|
||||
}
|
||||
mSpeakMode!!.speakText("结束录音")
|
||||
//获取右侧fragment容器
|
||||
val naviController = (context as Activity).findNavController(R.id.main_activity_right_fragment)
|
||||
val bundle = Bundle()
|
||||
bundle.putString("filePath", filePath)
|
||||
naviController.navigate(R.id.EvaluationResultFragment, bundle)
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.Q)
|
||||
override fun onfaild(message: String?) {
|
||||
ToastUtils.showLong("录制失败!")
|
||||
mSpeakMode!!.speakText("录制失败")
|
||||
stopSoundMeter()
|
||||
}
|
||||
})
|
||||
|
||||
mSoundMeter!!.start(Constant.USER_DATA_ATTACHEMNT_PATH + name)
|
||||
ToastUtils.showLong("开始录音")
|
||||
mSpeakMode!!.speakText("开始录音")
|
||||
}
|
||||
|
||||
//停止语音录制
|
||||
@RequiresApi(api = Build.VERSION_CODES.Q)
|
||||
fun stopSoundMeter() {
|
||||
//先重置标识,防止按钮抬起时触发语音结束
|
||||
Constant.IS_VIDEO_SPEED = false
|
||||
if (mSoundMeter != null && mSoundMeter!!.isStartSound()) {
|
||||
mSoundMeter!!.stop()
|
||||
}
|
||||
if (pop != null && pop!!.isShowing) pop!!.dismiss()
|
||||
}
|
||||
// fun startSaveTraceThread(context: Context) {
|
||||
// Thread(Runnable {
|
||||
// try {
|
||||
// while (true) {
|
||||
//
|
||||
// if (niLocationList != null && niLocationList.size > 0) {
|
||||
//
|
||||
// var niLocation = niLocationList[0]
|
||||
// val geometry = GeometryTools.createGeometry(
|
||||
// GeoPoint(
|
||||
// niLocation.latitude,
|
||||
// niLocation.longitude
|
||||
// )
|
||||
// )
|
||||
// val tileX = RealmSet<Int>()
|
||||
// GeometryToolsKt.getTileXByGeometry(geometry.toString(), tileX)
|
||||
// val tileY = RealmSet<Int>()
|
||||
// GeometryToolsKt.getTileYByGeometry(geometry.toString(), tileY)
|
||||
//
|
||||
// //遍历存储tile对应的x与y的值
|
||||
// tileX.forEach { x ->
|
||||
// tileY.forEach { y ->
|
||||
// niLocation.tilex = x
|
||||
// niLocation.tiley = y
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// TraceDataBase.getDatabase(
|
||||
// context,
|
||||
// Constant.USER_DATA_PATH + "/trace.sqlite"
|
||||
// ).niLocationDao.insert(niLocation)
|
||||
// niLocationList.remove(niLocation)
|
||||
//
|
||||
// Log.e("qj", "saveTrace==${niLocationList.size}")
|
||||
// }
|
||||
// Thread.sleep(30)
|
||||
// }
|
||||
// } catch (e: InterruptedException) {
|
||||
// e.printStackTrace()
|
||||
// Log.e("qj", "异常==${e.message}")
|
||||
// }
|
||||
// }).start()
|
||||
// }
|
||||
|
||||
// //增加轨迹存储
|
||||
// fun addSaveTrace(niLocation: NiLocation) {
|
||||
// if (niLocation != null && niLocationList != null) {
|
||||
// niLocationList.add(niLocation)
|
||||
// }
|
||||
// }
|
||||
|
||||
/**
|
||||
* 处理页面调转
|
||||
*/
|
||||
fun navigation(activity: MainActivity, list: List<String>) {
|
||||
//获取右侧fragment容器
|
||||
val naviController = activity.findNavController(R.id.main_activity_right_fragment)
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.navinfo.omqs.ui.activity.map
|
||||
|
||||
import android.view.LayoutInflater
|
||||
import android.view.ViewGroup
|
||||
import com.navinfo.omqs.R
|
||||
import com.navinfo.omqs.databinding.AdapterSignBinding
|
||||
import com.navinfo.omqs.ui.other.BaseRecyclerViewAdapter
|
||||
import com.navinfo.omqs.ui.other.BaseViewHolder
|
||||
|
||||
class SignAdapter : BaseRecyclerViewAdapter<SignBean>() {
|
||||
override fun getItemViewRes(position: Int): Int {
|
||||
return R.layout.adapter_sign
|
||||
}
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): BaseViewHolder {
|
||||
val viewBinding =
|
||||
AdapterSignBinding.inflate(LayoutInflater.from(parent.context), parent, false)
|
||||
return BaseViewHolder(viewBinding)
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: BaseViewHolder, position: Int) {
|
||||
val bd = holder.viewBinding as AdapterSignBinding
|
||||
val item = data[position]
|
||||
bd.signMainIcon.background = holder.viewBinding.root.context.getDrawable(item.iconId)
|
||||
bd.signMainIcon.text = item.iconText
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package com.navinfo.omqs.ui.activity.map
|
||||
|
||||
data class SignBean(
|
||||
//图标ID
|
||||
val iconId: Int,
|
||||
val distance: Int = 0,
|
||||
val iconText: String = ""
|
||||
)
|
||||
@@ -72,7 +72,7 @@ class EvaluationResultFragment : BaseFragment(), View.OnClickListener {
|
||||
if (arguments != null) {
|
||||
val id = requireArguments().getString("QsId")
|
||||
if (id != null) {
|
||||
viewModel.loadData(id)
|
||||
viewModel.initData(id)
|
||||
} else {
|
||||
viewModel.initNewData()
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import com.navinfo.collect.library.data.entity.QsRecordBean
|
||||
import com.navinfo.collect.library.data.entity.RenderEntity.Companion.LinkTable
|
||||
import com.navinfo.collect.library.map.NIMapController
|
||||
import com.navinfo.collect.library.utils.GeometryTools
|
||||
import com.navinfo.omqs.Constant
|
||||
@@ -19,6 +20,7 @@ import io.realm.Realm
|
||||
import io.realm.kotlin.where
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import org.oscim.core.GeoPoint
|
||||
import java.util.*
|
||||
import javax.inject.Inject
|
||||
|
||||
@@ -62,31 +64,24 @@ class EvaluationResultViewModel @Inject constructor(
|
||||
init {
|
||||
liveDataQsRecordBean.value = QsRecordBean(id = UUID.randomUUID().toString())
|
||||
Log.e("jingo", "EvaluationResultViewModel 创建了 ${hashCode()}")
|
||||
mapController.markerHandle.run {
|
||||
setOnMapClickListener {
|
||||
liveDataQsRecordBean.value!!.geometry = it.toGeometry()
|
||||
addMarker(it, markerTitle)
|
||||
viewModelScope.launch {
|
||||
mapController.onMapClickFlow.collect {
|
||||
liveDataQsRecordBean.value!!.geometry = GeometryTools.createGeometry(it).toText()
|
||||
mapController.markerHandle.addMarker(it, markerTitle)
|
||||
viewModelScope.launch {
|
||||
val linkList = realmOperateHelper.queryLink(
|
||||
point = GeometryTools.createPoint(
|
||||
it.longitude,
|
||||
it.latitude
|
||||
), sort = true
|
||||
)
|
||||
if (linkList.isNotEmpty()) {
|
||||
liveDataQsRecordBean.value!!.linkId = linkList[0].id
|
||||
}
|
||||
captureLink(it.longitude, it.latitude)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
override fun onCleared() {
|
||||
super.onCleared()
|
||||
Log.e("jingo", "EvaluationResultViewModel 销毁了 ${hashCode()}")
|
||||
mapController.markerHandle.removeMarker(markerTitle)
|
||||
mapController.markerHandle.removeOnMapClickListener()
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
mapController.lineHandler.removeLine()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -100,17 +95,34 @@ class EvaluationResultViewModel @Inject constructor(
|
||||
}
|
||||
val geoPoint = mapController.locationLayerHandler.getCurrentGeoPoint()
|
||||
geoPoint?.let {
|
||||
liveDataQsRecordBean.value!!.geometry = it.toGeometry()
|
||||
liveDataQsRecordBean.value!!.geometry = GeometryTools.createGeometry(it).toText()
|
||||
mapController.markerHandle.addMarker(geoPoint, markerTitle)
|
||||
viewModelScope.launch {
|
||||
val linkList = realmOperateHelper.queryLink(
|
||||
GeometryTools.createPoint(
|
||||
geoPoint.longitude,
|
||||
geoPoint.latitude
|
||||
)
|
||||
)
|
||||
captureLink(geoPoint.longitude, geoPoint.latitude)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 捕捉到路
|
||||
*/
|
||||
private suspend fun captureLink(longitude: Double, latitude: Double) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
val linkList = realmOperateHelper.queryLink(
|
||||
point = GeometryTools.createPoint(
|
||||
longitude,
|
||||
latitude
|
||||
),
|
||||
)
|
||||
|
||||
liveDataQsRecordBean.value?.let {
|
||||
if (linkList.isNotEmpty()) {
|
||||
liveDataQsRecordBean.value!!.linkId = linkList[0].id
|
||||
it.linkId =
|
||||
linkList[0].properties[LinkTable.linkPid] ?: ""
|
||||
mapController.lineHandler.showLine(linkList[0].geometry)
|
||||
} else {
|
||||
it.linkId = ""
|
||||
mapController.lineHandler.removeLine()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -270,14 +282,31 @@ class EvaluationResultViewModel @Inject constructor(
|
||||
/**
|
||||
* 根据数据id,查询数据
|
||||
*/
|
||||
fun loadData(id: String) {
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
val realm = Realm.getDefaultInstance()
|
||||
val objects = realm.where<QsRecordBean>().equalTo("id", id).findFirst()
|
||||
|
||||
if (objects != null) {
|
||||
oldBean = realm.copyFromRealm(objects)
|
||||
liveDataQsRecordBean.postValue(oldBean!!.copy())
|
||||
fun initData(id: String) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
val realm = Realm.getDefaultInstance()
|
||||
val objects = realm.where<QsRecordBean>().equalTo("id", id).findFirst()
|
||||
|
||||
if (objects != null) {
|
||||
oldBean = realm.copyFromRealm(objects)
|
||||
oldBean?.let {
|
||||
liveDataQsRecordBean.postValue(it.copy())
|
||||
val p = GeometryTools.createGeoPoint(it.geometry)
|
||||
mapController.markerHandle.addMarker(
|
||||
GeoPoint(p.latitude, p.longitude),
|
||||
markerTitle
|
||||
)
|
||||
|
||||
if (it.linkId.isNotEmpty()) {
|
||||
val link = realmOperateHelper.queryLink(it.linkId)
|
||||
link?.let { l ->
|
||||
mapController.lineHandler.showLine(l.geometry)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
package com.navinfo.omqs.ui.fragment.evaluationresult
|
||||
|
||||
import android.os.Build
|
||||
import android.view.LayoutInflater
|
||||
import android.view.ViewGroup
|
||||
import androidx.annotation.RequiresApi
|
||||
import com.navinfo.omqs.R
|
||||
import com.navinfo.omqs.databinding.TextItemSelectBinding
|
||||
import com.navinfo.omqs.ui.other.BaseRecyclerViewAdapter
|
||||
@@ -21,6 +23,7 @@ class MiddleAdapter(private var itemListener: ((Int, String) -> Unit?)? = null)
|
||||
return BaseViewHolder(viewBinding)
|
||||
}
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.M)
|
||||
override fun onBindViewHolder(holder: BaseViewHolder, position: Int) {
|
||||
val bd = holder.viewBinding as TextItemSelectBinding
|
||||
val title = data[position]
|
||||
|
||||
@@ -109,8 +109,7 @@ class PersonalCenterFragment : BaseFragment(), FSAFActivityCallbacks {
|
||||
R.id.personal_center_menu_test -> {
|
||||
viewModel.readRealmData()
|
||||
// 定位到指定位置
|
||||
niMapController.mMapView.vtmMap.animator()
|
||||
.animateTo(GeoPoint(30.270367985798032, 113.83513667119433))
|
||||
niMapController.mMapView.vtmMap.animator().animateTo(GeoPoint(30.226256855699773, 113.84660523913344))
|
||||
}
|
||||
R.id.personal_center_menu_task_list -> {
|
||||
findNavController().navigate(R.id.TaskListFragment)
|
||||
|
||||
@@ -1,11 +1,16 @@
|
||||
package com.navinfo.omqs.ui.fragment.tasklist
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.Color
|
||||
import android.os.Build
|
||||
import android.util.Log
|
||||
import android.widget.Toast
|
||||
import androidx.annotation.RequiresApi
|
||||
import androidx.core.graphics.toColor
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import com.navinfo.collect.library.map.NIMapController
|
||||
import com.navinfo.omqs.bean.TaskBean
|
||||
import com.navinfo.omqs.http.NetResult
|
||||
import com.navinfo.omqs.http.NetworkService
|
||||
@@ -19,7 +24,8 @@ import javax.inject.Inject
|
||||
|
||||
@HiltViewModel
|
||||
class TaskListViewModel @Inject constructor(
|
||||
private val networkService: NetworkService
|
||||
private val networkService: NetworkService,
|
||||
private val niMapController: NIMapController
|
||||
) : ViewModel() {
|
||||
|
||||
val liveDataTaskList = MutableLiveData<List<TaskBean>>()
|
||||
@@ -70,6 +76,11 @@ class TaskListViewModel @Inject constructor(
|
||||
for (item in taskList) {
|
||||
FileManager.checkOMDBFileInfo(item)
|
||||
}
|
||||
// niMapController.lineHandler.omdbTaskLinkLayer.setLineColor(Color.rgb(0, 255, 0).toColor())
|
||||
// taskList.forEach {
|
||||
// niMapController.lineHandler.omdbTaskLinkLayer.addLineList(it.hadLinkDvoList)
|
||||
// }
|
||||
// niMapController.lineHandler.omdbTaskLinkLayer.update()
|
||||
liveDataTaskList.postValue(taskList)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user