重构轨迹回放业务

This commit is contained in:
qiji4215 2023-07-18 15:45:11 +08:00
parent dfbea188ea
commit 78bd363372
12 changed files with 334 additions and 51 deletions

View File

@ -0,0 +1,8 @@
package com.navinfo.omqs.bean
data class TraceVideoBean(
var userid: String = "",
var playMode: String = "",
var time: String = "",
var command: String = "",
)

View File

@ -6,8 +6,7 @@ import com.navinfo.omqs.bean.IndoorConnectionInfoBean
import com.navinfo.omqs.bean.LoginUserBean import com.navinfo.omqs.bean.LoginUserBean
import com.navinfo.omqs.bean.QRCodeBean import com.navinfo.omqs.bean.QRCodeBean
import com.navinfo.omqs.bean.SysUserBean import com.navinfo.omqs.bean.SysUserBean
import okhttp3.ResponseBody import com.navinfo.omqs.bean.TraceVideoBean
import retrofit2.Response
/** /**
@ -38,4 +37,9 @@ interface NetworkService {
* 更新用户信息 * 更新用户信息
*/ */
suspend fun updateServerInfo(url: String,indoorConnectionInfoBean: IndoorConnectionInfoBean): NetResult<QRCodeBean> suspend fun updateServerInfo(url: String,indoorConnectionInfoBean: IndoorConnectionInfoBean): NetResult<QRCodeBean>
/**
* 设置轨迹对应的视频
*/
suspend fun sendServerCommand(url: String,traceVideoBean: TraceVideoBean): NetResult<QRCodeBean>
} }

View File

@ -6,6 +6,7 @@ import com.navinfo.omqs.bean.IndoorConnectionInfoBean
import com.navinfo.omqs.bean.LoginUserBean import com.navinfo.omqs.bean.LoginUserBean
import com.navinfo.omqs.bean.QRCodeBean import com.navinfo.omqs.bean.QRCodeBean
import com.navinfo.omqs.bean.SysUserBean import com.navinfo.omqs.bean.SysUserBean
import com.navinfo.omqs.bean.TraceVideoBean
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext import kotlinx.coroutines.withContext
import okhttp3.ResponseBody import okhttp3.ResponseBody
@ -110,6 +111,33 @@ class NetworkServiceImpl @Inject constructor(
map["baseurl"] = indoorConnectionInfoBean.baseurl map["baseurl"] = indoorConnectionInfoBean.baseurl
map["platform"] = indoorConnectionInfoBean.platform map["platform"] = indoorConnectionInfoBean.platform
val result = netApi.retrofitUpdateServerInfo(url,map)
if (result.isSuccessful) {
if (result.code() == 200) {
NetResult.Success(result.body())
} else {
NetResult.Failure<Any>(result.code(), result.message())
}
} else {
NetResult.Failure<Any>(result.code(), result.message())
}
} catch (e: Exception) {
NetResult.Error<Any>(e)
}
}
override suspend fun sendServerCommand(
url: String,
traceVideoBean: TraceVideoBean
): NetResult<QRCodeBean> =
//在IO线程中运行
withContext(Dispatchers.IO) {
return@withContext try {
val map: MutableMap<String, String> = HashMap()
map["userid"] = traceVideoBean.userid
map["playMode"] = traceVideoBean.playMode
map["time"] = traceVideoBean.time
val result = netApi.retrofitUpdateServerInfo(url,map) val result = netApi.retrofitUpdateServerInfo(url,map)
if (result.isSuccessful) { if (result.isSuccessful) {
if (result.code() == 200) { if (result.code() == 200) {

View File

@ -20,11 +20,13 @@ import androidx.navigation.findNavController
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import com.google.android.material.dialog.MaterialAlertDialogBuilder import com.google.android.material.dialog.MaterialAlertDialogBuilder
import com.navinfo.collect.library.data.entity.NiLocation
import com.navinfo.collect.library.map.NIMapController import com.navinfo.collect.library.map.NIMapController
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.ImportConfig import com.navinfo.omqs.bean.ImportConfig
import com.navinfo.omqs.bean.SignBean import com.navinfo.omqs.bean.SignBean
import com.navinfo.omqs.bean.TraceVideoBean
import com.navinfo.omqs.databinding.ActivityMainBinding import com.navinfo.omqs.databinding.ActivityMainBinding
import com.navinfo.omqs.http.offlinemapdownload.OfflineMapDownloadManager import com.navinfo.omqs.http.offlinemapdownload.OfflineMapDownloadManager
import com.navinfo.omqs.tools.LayerConfigUtils import com.navinfo.omqs.tools.LayerConfigUtils
@ -34,12 +36,14 @@ import com.navinfo.omqs.ui.fragment.offlinemap.OfflineMapFragment
import com.navinfo.omqs.ui.fragment.qsrecordlist.QsRecordListFragment import com.navinfo.omqs.ui.fragment.qsrecordlist.QsRecordListFragment
import com.navinfo.omqs.ui.fragment.signMoreInfo.SignMoreInfoFragment import com.navinfo.omqs.ui.fragment.signMoreInfo.SignMoreInfoFragment
import com.navinfo.omqs.ui.fragment.tasklist.TaskManagerFragment import com.navinfo.omqs.ui.fragment.tasklist.TaskManagerFragment
import com.navinfo.omqs.ui.other.BaseToast
import com.navinfo.omqs.ui.widget.RecyclerViewSpacesItemDecoration import com.navinfo.omqs.ui.widget.RecyclerViewSpacesItemDecoration
import com.navinfo.omqs.util.FlowEventBus import com.navinfo.omqs.util.FlowEventBus
import com.navinfo.omqs.util.SpeakMode import com.navinfo.omqs.util.SpeakMode
import dagger.hilt.android.AndroidEntryPoint import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import org.oscim.core.GeoPoint import org.oscim.core.GeoPoint
import org.oscim.layers.marker.MarkerItem
import org.oscim.renderer.GLViewport import org.oscim.renderer.GLViewport
import org.videolan.vlc.Util import org.videolan.vlc.Util
import java.math.BigDecimal import java.math.BigDecimal
@ -227,7 +231,10 @@ class MainActivity : BaseActivity() {
//捕捉列表变化回调 //捕捉列表变化回调
viewModel.liveDataNILocationList.observe(this) { viewModel.liveDataNILocationList.observe(this) {
if(viewModel.isSelectTrace()){ if(viewModel.isSelectTrace()){
Toast.makeText(this,"轨迹被点击了",Toast.LENGTH_LONG).show() //Toast.makeText(this,"轨迹被点击了",Toast.LENGTH_LONG).show()
viewModel.showMarker(this,it)
val traceVideoBean = TraceVideoBean(command = "videotime?", userid = Constant.USER_ID, time = "${it.time}:000")
viewModel.sendServerCommand(this,traceVideoBean)
} }
} }
@ -535,10 +542,17 @@ class MainActivity : BaseActivity() {
@RequiresApi(Build.VERSION_CODES.N) @RequiresApi(Build.VERSION_CODES.N)
fun tracePointsOnclick() { fun tracePointsOnclick() {
viewModel.setSelectTrace(!viewModel.isSelectTrace()) viewModel.setSelectTrace(!viewModel.isSelectTrace())
binding.mainActivityTraceSnapshotPoints.isSelected = viewModel.isSelectTrace()
if(viewModel.isSelectTrace()){ if(viewModel.isSelectTrace()){
Toast.makeText(this,"请选择轨迹点!",Toast.LENGTH_LONG).show() Toast.makeText(this,"请选择轨迹点!",Toast.LENGTH_LONG).show()
//调用撤销自动播放
binding.mainActivitySnapshotFinish.isEnabled = false
binding.mainActivitySnapshotRewind.isEnabled = false
binding.mainActivitySnapshotPause.isEnabled = false
binding.mainActivitySnapshotNext.isEnabled = false
viewModel.cancelTrace()
} }
binding.mainActivityTraceSnapshotPoints.isSelected = viewModel.isSelectTrace()
} }
/** /**
@ -550,6 +564,7 @@ class MainActivity : BaseActivity() {
viewModel.setSelectTrace(false) viewModel.setSelectTrace(false)
viewModel.setMediaFlag(false) viewModel.setMediaFlag(false)
viewModel.setSelectPauseTrace(false) viewModel.setSelectPauseTrace(false)
binding.mainActivityMenuIndoorGroup.visibility = View.GONE
binding.mainActivityTraceSnapshotPoints.isSelected = viewModel.isSelectTrace() binding.mainActivityTraceSnapshotPoints.isSelected = viewModel.isSelectTrace()
binding.mainActivitySnapshotMediaFlag.isSelected = viewModel.isMediaFlag() binding.mainActivitySnapshotMediaFlag.isSelected = viewModel.isMediaFlag()
binding.mainActivitySnapshotPause.isSelected = viewModel.isSelectPauseTrace() binding.mainActivitySnapshotPause.isSelected = viewModel.isSelectPauseTrace()
@ -569,7 +584,16 @@ class MainActivity : BaseActivity() {
*/ */
@RequiresApi(Build.VERSION_CODES.N) @RequiresApi(Build.VERSION_CODES.N)
fun rewindTraceOnclick() { fun rewindTraceOnclick() {
pasePlayTrace() pausePlayTrace()
val item = mapController.markerHandle.getNILocation(viewModel.currentIndexNiLocation-1)
if(item!=null){
viewModel.currentIndexNiLocation = viewModel.currentIndexNiLocation-1
viewModel.showMarker(this,(item as MarkerItem).uid as NiLocation)
val traceVideoBean = TraceVideoBean(command = "videotime?", userid = Constant.USER_ID, time = "${(item.uid as NiLocation).time}:000")
viewModel.sendServerCommand(this,traceVideoBean)
}else{
dealNoData()
}
} }
/** /**
@ -581,6 +605,41 @@ class MainActivity : BaseActivity() {
binding.mainActivitySnapshotPause.isSelected = viewModel.isSelectPauseTrace() binding.mainActivitySnapshotPause.isSelected = viewModel.isSelectPauseTrace()
viewModel.setSelectTrace(false) viewModel.setSelectTrace(false)
binding.mainActivityTraceSnapshotPoints.isSelected = viewModel.isSelectTrace() binding.mainActivityTraceSnapshotPoints.isSelected = viewModel.isSelectTrace()
if(viewModel.isSelectPauseTrace()){
playVideo()
}else{
pauseVideo()
viewModel.cancelTrace()
}
}
@RequiresApi(Build.VERSION_CODES.N)
fun playVideo(){
if (mapController.markerHandle.getCurrentMark()==null) {
BaseToast.makeText(this, "请先选择轨迹点!", BaseToast.LENGTH_SHORT).show()
return
}
viewModel.setSelectTrace(false)
binding.mainActivityTraceSnapshotPoints.isSelected = viewModel.isSelectTrace()
val traceVideoBean = TraceVideoBean(command = "playVideo?", userid = Constant.USER_ID)
viewModel.sendServerCommand(this,traceVideoBean)
}
/**
* 设置为播放状态
*/
@RequiresApi(Build.VERSION_CODES.N)
fun setPlayStatus() {
//切换为播放
viewModel.setSelectPauseTrace(true)
binding.mainActivitySnapshotPause.isSelected = viewModel.isSelectPauseTrace()
playVideo()
}
@RequiresApi(Build.VERSION_CODES.N)
fun pauseVideo(){
val traceVideoBean = TraceVideoBean(command = "pauseVideo?", userid = Constant.USER_ID)
viewModel.sendServerCommand(this,traceVideoBean)
} }
/** /**
@ -588,15 +647,38 @@ class MainActivity : BaseActivity() {
*/ */
@RequiresApi(Build.VERSION_CODES.N) @RequiresApi(Build.VERSION_CODES.N)
fun nextTraceOnclick() { fun nextTraceOnclick() {
pasePlayTrace() pausePlayTrace()
val item = mapController.markerHandle.getNILocation(viewModel.currentIndexNiLocation+1)
if(item!=null){
viewModel.currentIndexNiLocation = viewModel.currentIndexNiLocation+1
viewModel.showMarker(this,(item as MarkerItem).uid as NiLocation)
val traceVideoBean = TraceVideoBean(command = "videotime?", userid = Constant.USER_ID, time = "${(item.uid as NiLocation).time}:000")
viewModel.sendServerCommand(this,traceVideoBean)
}else{
dealNoData()
}
} }
@RequiresApi(Build.VERSION_CODES.N) @RequiresApi(Build.VERSION_CODES.N)
fun pasePlayTrace() { private fun dealNoData() {
BaseToast.makeText(this, "无数据了!", Toast.LENGTH_SHORT).show()
//无数据时自动暂停播放,并停止轨迹
if (viewModel.isSelectPauseTrace()) {
pauseVideo()
viewModel.cancelTrace()
viewModel.setSelectPauseTrace(false)
binding.mainActivitySnapshotPause.isSelected = viewModel.isSelectPauseTrace()
}
}
@RequiresApi(Build.VERSION_CODES.N)
fun pausePlayTrace() {
viewModel.setSelectTrace(false) viewModel.setSelectTrace(false)
binding.mainActivityTraceSnapshotPoints.isSelected = viewModel.isSelectTrace() binding.mainActivityTraceSnapshotPoints.isSelected = viewModel.isSelectTrace()
viewModel.setSelectPauseTrace(false) viewModel.setSelectPauseTrace(false)
binding.mainActivitySnapshotPause.isSelected = viewModel.isSelectPauseTrace() binding.mainActivitySnapshotPause.isSelected = viewModel.isSelectPauseTrace()
viewModel.cancelTrace()
} }

View File

@ -15,10 +15,10 @@ import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.widget.ImageView import android.widget.ImageView
import android.widget.PopupWindow import android.widget.PopupWindow
import android.widget.Toast
import androidx.annotation.RequiresApi import androidx.annotation.RequiresApi
import androidx.lifecycle.MutableLiveData import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel import androidx.lifecycle.ViewModel
import androidx.lifecycle.lifecycleScope
import androidx.lifecycle.viewModelScope import androidx.lifecycle.viewModelScope
import androidx.navigation.findNavController import androidx.navigation.findNavController
import com.blankj.utilcode.util.ToastUtils import com.blankj.utilcode.util.ToastUtils
@ -35,10 +35,16 @@ import com.navinfo.collect.library.utils.GeometryToolsKt
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.ImportConfig import com.navinfo.omqs.bean.ImportConfig
import com.navinfo.omqs.bean.QRCodeBean
import com.navinfo.omqs.bean.SignBean import com.navinfo.omqs.bean.SignBean
import com.navinfo.omqs.bean.TraceVideoBean
import com.navinfo.omqs.db.RealmOperateHelper import com.navinfo.omqs.db.RealmOperateHelper
import com.navinfo.omqs.http.NetResult
import com.navinfo.omqs.http.NetworkService
import com.navinfo.omqs.ui.activity.scan.QrCodeStatus
import com.navinfo.omqs.ui.dialog.CommonDialog import com.navinfo.omqs.ui.dialog.CommonDialog
import com.navinfo.omqs.ui.manager.TakePhotoManager import com.navinfo.omqs.ui.manager.TakePhotoManager
import com.navinfo.omqs.ui.other.BaseToast
import com.navinfo.omqs.ui.widget.SignUtil import com.navinfo.omqs.ui.widget.SignUtil
import com.navinfo.omqs.util.DateTimeUtil import com.navinfo.omqs.util.DateTimeUtil
import com.navinfo.omqs.util.SoundMeter import com.navinfo.omqs.util.SoundMeter
@ -56,6 +62,7 @@ import org.oscim.core.MapPosition
import org.oscim.map.Map import org.oscim.map.Map
import org.videolan.libvlc.LibVlcUtil import org.videolan.libvlc.LibVlcUtil
import java.io.File import java.io.File
import java.io.IOException
import java.util.* import java.util.*
import javax.inject.Inject import javax.inject.Inject
@ -69,6 +76,7 @@ class MainViewModel @Inject constructor(
private val mapController: NIMapController, private val mapController: NIMapController,
private val traceDataBase: TraceDataBase, private val traceDataBase: TraceDataBase,
private val realmOperateHelper: RealmOperateHelper, private val realmOperateHelper: RealmOperateHelper,
private val networkService: NetworkService,
private val sharedPreferences: SharedPreferences private val sharedPreferences: SharedPreferences
) : ViewModel() { ) : ViewModel() {
@ -97,6 +105,8 @@ class MainViewModel @Inject constructor(
*/ */
val liveDataSignMoreInfo = MutableLiveData<RenderEntity>() val liveDataSignMoreInfo = MutableLiveData<RenderEntity>()
private var traceTag: String = "TRACE_TAG"
// var testPoint = GeoPoint(0, 0) // var testPoint = GeoPoint(0, 0)
//uuid标识用于记录轨迹组 //uuid标识用于记录轨迹组
@ -120,6 +130,9 @@ class MainViewModel @Inject constructor(
val liveDataCenterPoint = MutableLiveData<MapPosition>() val liveDataCenterPoint = MutableLiveData<MapPosition>()
//状态
val qrCodeStatus: MutableLiveData<QrCodeStatus> = MutableLiveData()
/** /**
* 是不是线选择模式 * 是不是线选择模式
*/ */
@ -144,6 +157,8 @@ class MainViewModel @Inject constructor(
private var lastNiLocaion: NiLocation? = null private var lastNiLocaion: NiLocation? = null
var currentIndexNiLocation: Int = 0;
init { init {
mapController.mMapView.vtmMap.events.bind(Map.UpdateListener { e, mapPosition -> mapController.mMapView.vtmMap.events.bind(Map.UpdateListener { e, mapPosition ->
when (e) { when (e) {
@ -163,8 +178,9 @@ class MainViewModel @Inject constructor(
liveDataNoteIdList.value = list liveDataNoteIdList.value = list
} }
override fun onNiLocation(item: NiLocation) { override fun onNiLocation(index: Int, item: NiLocation) {
liveDataNILocationList.value = item liveDataNILocationList.value = item
currentIndexNiLocation = index
} }
}) })
@ -175,7 +191,7 @@ class MainViewModel @Inject constructor(
mapController.onMapClickFlow.collectLatest { mapController.onMapClickFlow.collectLatest {
// testPoint = it // testPoint = it
//线选择状态 //线选择状态
/* if (bSelectRoad) { /* if (bSelectRoad) {
captureLink(it) captureLink(it)
} else { } else {
captureItem(it) captureItem(it)
@ -259,7 +275,7 @@ class MainViewModel @Inject constructor(
mapController.locationLayerHandler.niLocationFlow.collect { location -> mapController.locationLayerHandler.niLocationFlow.collect { location ->
//过滤掉无效点 //过滤掉无效点
if(!GeometryTools.isCheckError(location.longitude,location.latitude)){ if (!GeometryTools.isCheckError(location.longitude, location.latitude)) {
val geometry = GeometryTools.createGeometry( val geometry = GeometryTools.createGeometry(
GeoPoint( GeoPoint(
location.latitude, location.longitude location.latitude, location.longitude
@ -289,9 +305,10 @@ class MainViewModel @Inject constructor(
if (lastNiLocaion != null) { if (lastNiLocaion != null) {
val disance = GeometryTools.getDistance( val disance = GeometryTools.getDistance(
location.latitude, location.longitude, location.latitude, location.longitude,
lastNiLocaion!!.latitude, lastNiLocaion!!.longitude) lastNiLocaion!!.latitude, lastNiLocaion!!.longitude
)
//相距差距大于2.5米以上进行存储 //相距差距大于2.5米以上进行存储
if (disance > 2.5) { if (disance > 2.5 && disance < 60) {
traceDataBase.niLocationDao.insert(location) traceDataBase.niLocationDao.insert(location)
mapController.markerHandle.addNiLocationMarkerItem(location) mapController.markerHandle.addNiLocationMarkerItem(location)
mapController.mMapView.vtmMap.updateMap(true) mapController.mMapView.vtmMap.updateMap(true)
@ -299,8 +316,8 @@ class MainViewModel @Inject constructor(
} }
} else { } else {
traceDataBase.niLocationDao.insert(location) traceDataBase.niLocationDao.insert(location)
/* mapController.markerHandle.addNiLocationMarkerItem(location) mapController.markerHandle.addNiLocationMarkerItem(location)
mapController.mMapView.vtmMap.updateMap(true)*/ mapController.mMapView.vtmMap.updateMap(true)
lastNiLocaion = location lastNiLocaion = location
} }
} }
@ -309,7 +326,11 @@ class MainViewModel @Inject constructor(
//用于定位点捕捉道路 //用于定位点捕捉道路
viewModelScope.launch(Dispatchers.Default) { viewModelScope.launch(Dispatchers.Default) {
mapController.locationLayerHandler.niLocationFlow.collectLatest { location -> mapController.locationLayerHandler.niLocationFlow.collectLatest { location ->
if (!isSelectRoad()&&!GeometryTools.isCheckError(location.longitude,location.latitude)) captureLink( if (!isSelectRoad() && !GeometryTools.isCheckError(
location.longitude,
location.latitude
)
) captureLink(
GeoPoint( GeoPoint(
location.latitude, location.latitude,
location.longitude location.longitude
@ -335,11 +356,11 @@ class MainViewModel @Inject constructor(
*/ */
@RequiresApi(Build.VERSION_CODES.N) @RequiresApi(Build.VERSION_CODES.N)
private suspend fun captureLink(point: GeoPoint) { private suspend fun captureLink(point: GeoPoint) {
if(captureLinkState){ if (captureLinkState) {
return return
} }
try{ try {
captureLinkState = true captureLinkState = true
val linkList = realmOperateHelper.queryLink( val linkList = realmOperateHelper.queryLink(
@ -437,9 +458,9 @@ class MainViewModel @Inject constructor(
liveDataRoadName.postValue(null) liveDataRoadName.postValue(null)
} }
}catch (e:Exception){ } catch (e: Exception) {
}finally { } finally {
captureLinkState = false captureLinkState = false
} }
@ -673,5 +694,114 @@ class MainViewModel @Inject constructor(
liveDataSignMoreInfo.value = data liveDataSignMoreInfo.value = data
} }
fun sendServerCommand(context: Context, traceVideoBean: TraceVideoBean) {
if (TextUtils.isEmpty(Constant.INDOOR_IP)) {
Toast.makeText(context, "获取ip失败", Toast.LENGTH_LONG).show()
return
}
viewModelScope.launch(Dispatchers.Default) {
val url = "http://${Constant.INDOOR_IP}:8080/sensor/service/${traceVideoBean.command}?"
when (val result = networkService.sendServerCommand(
url = url,
traceVideoBean = traceVideoBean
)) {
is NetResult.Success<*> -> {
if (result.data != null) {
try {
val defaultUserResponse = result.data as QRCodeBean
if (defaultUserResponse.errcode == 0) {
withContext(Dispatchers.Main) {
Toast.makeText(
context,
"命令成功。",
Toast.LENGTH_LONG
).show()
qrCodeStatus.postValue(QrCodeStatus.QR_CODE_STATUS_UPDATE_VIDEO_INFO_SUCCESS)
}
} else {
withContext(Dispatchers.Main) {
Toast.makeText(
context,
"命令无效${defaultUserResponse.errmsg}",
Toast.LENGTH_SHORT
)
.show()
}
}
} catch (e: IOException) {
withContext(Dispatchers.Main) {
Toast.makeText(
context,
"${e.message}",
Toast.LENGTH_SHORT
).show()
}
}
}
}
is NetResult.Error<*> -> {
withContext(Dispatchers.Main) {
Toast.makeText(
context,
"${result.exception.message}",
Toast.LENGTH_SHORT
)
.show()
}
qrCodeStatus.postValue(QrCodeStatus.QR_CODE_STATUS_NET_FAILURE)
}
is NetResult.Failure<*> -> {
withContext(Dispatchers.Main) {
Toast.makeText(
context,
"${result.code}:${result.msg}",
Toast.LENGTH_SHORT
)
.show()
}
qrCodeStatus.postValue(QrCodeStatus.QR_CODE_STATUS_NET_FAILURE)
}
else -> {}
}
}
}
/**
* 显示marker
* @param trackCollection 轨迹点
* @param type 1 提示最后一个轨迹点 非1提示第一个轨迹点
*/
fun showMarker(context: Context, niLocation: NiLocation) {
if (mapController.markerHandle != null) {
mapController.markerHandle.removeMarker(traceTag)
if (niLocation != null) {
mapController.markerHandle.addMarker(
GeoPoint(
niLocation.latitude,
niLocation.longitude
), traceTag, "", niLocation as java.lang.Object
)
}
}
}
/**
* 结束自动播放
*/
fun cancelTrace() {
}
} }

View File

@ -33,6 +33,16 @@ enum class QrCodeStatus {
* 信息更新成功 * 信息更新成功
*/ */
QR_CODE_STATUS_SERVER_INFO_SUCCESS, QR_CODE_STATUS_SERVER_INFO_SUCCESS,
/**
* 信息更新轨迹成功
*/
QR_CODE_STATUS_UPDATE_VIDEO_INFO_SUCCESS,
/**
* 信息更新轨迹失败
*/
QR_CODE_STATUS_UPDATE_VIDEO_INFO_FAILURE,
} }
@HiltViewModel @HiltViewModel

View File

@ -61,6 +61,12 @@ class QrCodeActivity : BaseActivity() {
} }
QrCodeStatus.QR_CODE_STATUS_SERVER_INFO_SUCCESS -> { QrCodeStatus.QR_CODE_STATUS_SERVER_INFO_SUCCESS -> {
}
QrCodeStatus.QR_CODE_STATUS_UPDATE_VIDEO_INFO_SUCCESS -> {
}
QrCodeStatus.QR_CODE_STATUS_UPDATE_VIDEO_INFO_FAILURE -> {
} }
} }
} }

View File

@ -212,6 +212,7 @@ class EvaluationResultViewModel @Inject constructor(
if (classType2 != null) { if (classType2 != null) {
classType = classType2 classType = classType2
} }
classCode = bean.renderEntity.code.toString()
} }
//如果右侧栏没数据,给个默认值 //如果右侧栏没数据,给个默认值
if (liveDataQsRecordBean.value!!.classType.isEmpty()) { if (liveDataQsRecordBean.value!!.classType.isEmpty()) {
@ -298,11 +299,12 @@ class EvaluationResultViewModel @Inject constructor(
/** /**
* 查询问题类型列表 * 查询问题类型列表
*/ */
fun getProblemTypeList(classType: String) { fun getProblemTypeList(scProblemTypeBean: ScProblemTypeBean) {
viewModelScope.launch(Dispatchers.IO) { viewModelScope.launch(Dispatchers.IO) {
getProblemList(classType) getProblemList(scProblemTypeBean.classType)
} }
classTypeTemp = classType classTypeTemp = scProblemTypeBean.classType
classCodeTemp = scProblemTypeBean.elementCode
} }
/** /**
@ -381,7 +383,7 @@ class EvaluationResultViewModel @Inject constructor(
GeoPoint( GeoPoint(
p.latitude, p.latitude,
p.longitude p.longitude
), markerTitle ), markerTitle,"",null
) )
//获取linkid //获取linkid

View File

@ -7,7 +7,7 @@ import com.navinfo.omqs.databinding.TextItemSelectBinding
import com.navinfo.omqs.ui.other.BaseRecyclerViewAdapter import com.navinfo.omqs.ui.other.BaseRecyclerViewAdapter
import com.navinfo.omqs.ui.other.BaseViewHolder import com.navinfo.omqs.ui.other.BaseViewHolder
class LeftAdapter(private var itemListener: ((Int, String) -> Unit?)? = null) : class LeftAdapter(private var itemListener: ((Int, ScProblemTypeBean) -> Unit?)? = null) :
BaseRecyclerViewAdapter<ScProblemTypeBean>() { BaseRecyclerViewAdapter<ScProblemTypeBean>() {
private var selectTitle = "" private var selectTitle = ""
@ -28,7 +28,7 @@ class LeftAdapter(private var itemListener: ((Int, String) -> Unit?)? = null) :
selectTitle = title.classType selectTitle = title.classType
notifyDataSetChanged() notifyDataSetChanged()
} }
itemListener?.invoke(position, title.classType) itemListener?.invoke(position, title)
} }
} }

View File

@ -380,6 +380,7 @@
<ImageButton <ImageButton
android:id="@+id/main_activity_snapshot_next" android:id="@+id/main_activity_snapshot_next"
style="@style/top_right_drawer_btns_style" style="@style/top_right_drawer_btns_style"
android:onClick="@{()->mainActivity.nextTraceOnclick()}"
android:src="@drawable/map_trace_next" /> android:src="@drawable/map_trace_next" />
<View <View

View File

@ -14,7 +14,7 @@ import java.util.UUID;
* @Date 2022/4/14 * @Date 2022/4/14
* @Description: ${TODO}(数据基类) * @Description: ${TODO}(数据基类)
*/ */
public class Feature implements Serializable, Cloneable { public class Feature extends Object implements Serializable, Cloneable {
// //主键 // //主键
// @PrimaryKey(autoGenerate = true) // @PrimaryKey(autoGenerate = true)
// public int rowId; // public int rowId;

View File

@ -1,15 +1,12 @@
package com.navinfo.collect.library.map.handler package com.navinfo.collect.library.map.handler
import android.content.Context import android.content.Context
import android.content.SharedPreferences
import android.graphics.BitmapFactory import android.graphics.BitmapFactory
import android.graphics.Canvas import android.graphics.Canvas
import android.graphics.Color import android.graphics.Color
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
import androidx.core.content.res.ResourcesCompat import androidx.core.content.res.ResourcesCompat
import androidx.lifecycle.lifecycleScope
import com.navinfo.collect.library.R import com.navinfo.collect.library.R
import com.navinfo.collect.library.data.dao.impl.TraceDataBase
import com.navinfo.collect.library.data.entity.NiLocation import com.navinfo.collect.library.data.entity.NiLocation
import com.navinfo.collect.library.data.entity.NoteBean import com.navinfo.collect.library.data.entity.NoteBean
import com.navinfo.collect.library.data.entity.QsRecordBean import com.navinfo.collect.library.data.entity.QsRecordBean
@ -20,11 +17,6 @@ import com.navinfo.collect.library.map.layers.MyItemizedLayer
import com.navinfo.collect.library.map.layers.NoteLineLayer import com.navinfo.collect.library.map.layers.NoteLineLayer
import com.navinfo.collect.library.utils.GeometryTools import com.navinfo.collect.library.utils.GeometryTools
import com.navinfo.collect.library.utils.StringUtil import com.navinfo.collect.library.utils.StringUtil
import io.realm.Realm
import io.realm.kotlin.where
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import org.locationtech.jts.geom.Geometry import org.locationtech.jts.geom.Geometry
import org.locationtech.jts.geom.LineString import org.locationtech.jts.geom.LineString
import org.locationtech.jts.geom.Polygon import org.locationtech.jts.geom.Polygon
@ -179,7 +171,7 @@ class MarkHandler(context: AppCompatActivity, mapView: NIMapView) :
object : OnItemGestureListener<MarkerInterface> { object : OnItemGestureListener<MarkerInterface> {
override fun onItemSingleTapUp(index: Int, item: MarkerInterface?): Boolean { override fun onItemSingleTapUp(index: Int, item: MarkerInterface?): Boolean {
itemListener?.let { itemListener?.let {
it.onNiLocation((niLocationItemizedLayer.itemList[index] as MarkerItem).uid as NiLocation) it.onNiLocation(index,(niLocationItemizedLayer.itemList[index] as MarkerItem).uid as NiLocation)
} }
return true return true
} }
@ -303,7 +295,8 @@ class MarkHandler(context: AppCompatActivity, mapView: NIMapView) :
fun addMarker( fun addMarker(
geoPoint: GeoPoint, geoPoint: GeoPoint,
title: String?, title: String?,
description: String? = "" description: String? = "",
uid: java.lang.Object?=null,
) { ) {
var marker: MarkerItem? = null var marker: MarkerItem? = null
for (e in mDefaultMarkerLayer.itemList) { for (e in mDefaultMarkerLayer.itemList) {
@ -318,6 +311,7 @@ class MarkHandler(context: AppCompatActivity, mapView: NIMapView) :
tempTitle = StringUtil.createUUID() tempTitle = StringUtil.createUUID()
} }
val marker = MarkerItem( val marker = MarkerItem(
uid,
tempTitle, tempTitle,
description, description,
geoPoint geoPoint
@ -333,6 +327,14 @@ class MarkHandler(context: AppCompatActivity, mapView: NIMapView) :
} }
} }
fun getCurrentMark(): MarkerInterface? {
if(mDefaultMarkerLayer!=null){
return mDefaultMarkerLayer.itemList[mDefaultMarkerLayer.itemList.size-1]
}
return null
}
/** /**
* 移除marker * 移除marker
*/ */
@ -520,9 +522,13 @@ class MarkHandler(context: AppCompatActivity, mapView: NIMapView) :
/** /**
* 添加质检数据marker * 添加质检数据marker
*/ */
public suspend fun addNiLocationMarkerItem(niLocation: NiLocation) { fun addNiLocationMarkerItem(niLocation: NiLocation) {
var geoMarkerItem = createNILocationBitmap(niLocation)
niLocationItemizedLayer.addItem(geoMarkerItem)
niLocationItemizedLayer.update()
}
var itemizedLayer: ItemizedLayer? = null private fun createNILocationBitmap(niLocation: NiLocation): MarkerItem{
val direction: Double = niLocation.direction val direction: Double = niLocation.direction
@ -548,8 +554,6 @@ class MarkHandler(context: AppCompatActivity, mapView: NIMapView) :
MarkerSymbol(niLocationBitmap2, MarkerSymbol.HotspotPlace.CENTER, false) MarkerSymbol(niLocationBitmap2, MarkerSymbol.HotspotPlace.CENTER, false)
geoMarkerItem.marker = symbolGpsTemp geoMarkerItem.marker = symbolGpsTemp
} }
niLocationItemizedLayer.addItem(geoMarkerItem)
itemizedLayer = niLocationItemizedLayer
} }
1 -> { 1 -> {
@ -565,14 +569,10 @@ class MarkHandler(context: AppCompatActivity, mapView: NIMapView) :
MarkerSymbol(niLocationBitmap3, MarkerSymbol.HotspotPlace.CENTER, false) MarkerSymbol(niLocationBitmap3, MarkerSymbol.HotspotPlace.CENTER, false)
geoMarkerItem.marker = symbolGpsTemp geoMarkerItem.marker = symbolGpsTemp
} }
niLocationItemizedLayer.addItem(geoMarkerItem) }
itemizedLayer = niLocationItemizedLayer
} }
} return geoMarkerItem
itemizedLayer!!.update()
} }
@ -794,10 +794,22 @@ class MarkHandler(context: AppCompatActivity, mapView: NIMapView) :
niLocationItemizedLayer.update() niLocationItemizedLayer.update()
} }
fun getNILocationItemizedLayerSize():Int{
return niLocationItemizedLayer.itemList.size
}
fun getNILocation(index:Int):MarkerInterface?{
return if(index>-1&&index<getNILocationItemizedLayerSize()){
niLocationItemizedLayer.itemList[index]
}else{
null
}
}
} }
interface OnQsRecordItemClickListener { interface OnQsRecordItemClickListener {
fun onQsRecordList(list: MutableList<String>) fun onQsRecordList(list: MutableList<String>)
fun onNoteList(list: MutableList<String>) fun onNoteList(list: MutableList<String>)
fun onNiLocation(it: NiLocation) fun onNiLocation(index:Int,it: NiLocation)
} }